Skip to content

Commit

Permalink
Initial commit from latest release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
vikashkum05 committed Jul 16, 2024
0 parents commit d90e916
Show file tree
Hide file tree
Showing 736 changed files with 143,969 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[run]
source = proco
omit = *migrations*,*tests*,*proco_data_migrations*,*/proco/*/admin.py,*dailycheckapp_contact*,*realtime_dailycheckapp*,*realtime_unicef*

[report]
fail_under = 70
skip_covered = False
skip_empty = True
sort = Cover


[html]
skip_covered = False
skip_empty = True
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
.env
media
!media/.gitkeep
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# https://editorconfig.org/
root = true

[*]
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8

# Docstrings and comments use max_line_length = 79
[*.py]
max_line_length = 120

# Use 2 spaces for the HTML files
[*.html]
indent_size = 2

# The JSON files contain newlines inconsistently
[*.json]
indent_size = 2
insert_final_newline = ignore

# Minified JavaScript files shouldn't be changed
[**.min.js]
indent_style = ignore
insert_final_newline = ignore

[*.yml]
indent_size = 2
61 changes: 61 additions & 0 deletions .env_example
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
DJANGO_SETTINGS_MODULE=config.settings.dev

DJANGO_SECRET_KEY=

PROJECT_FULL_NAME=gigamaps
PROJECT_SHORT_NAME=gigamaps

[email protected]
SUPPORT_PHONE_NUMBER=1234567890

# AZURE AD B2C settings
AD_B2C_TENANT_ID=
AD_B2C_CLIENT_ID=
AD_B2C_BASE_URL=
AD_B2C_DOMAIN=
AD_B2C_SIGNUP_SIGNIN_POLICY=B2C_1_UNICEF_SOCIAL_signup_signin
AD_B2C_FORGOT_PASSWORD_POLICY=B2C_1_PasswordResetPolicy
AD_B2C_EDIT_PROFILE_POLICY=B2C_1_ProfileEditingPolicy

SEARCH_ENDPOINT=
SEARCH_API_KEY=
COUNTRY_INDEX_NAME=giga-countries
SCHOOL_INDEX_NAME=giga-schools

MAILJET_API_URL=https://api.mailjet.com/v3
MAILJET_API_KEY=
MAILJET_SECRET_KEY=
[email protected]

DAILY_CHECK_APP_BASE_URL=https://uni-ooi-giga-daily-check-service-api-dev.azurewebsites.net/api/v1
DAILY_CHECK_APP_API_CODE=DAILY_CHECK_APP

CELERY_BROKER_URL=redis://redis:6379/1
CELERY_RESULT_BACKEND_URL=redis://redis:6379/2

DATA_LAYER_DASHBOARD_URL=http://localhost:9500/admin/giga-layer

SCHOOL_MASTER_SHARE_NAME=gold
SCHOOL_MASTER_SCHEMA_NAME=school-master
SCHOOL_MASTER_REVIEW_GRACE_PERIOD_IN_HRS=48
SCHOOL_MASTER_DASHBOARD_URL=http://localhost:9500/admin/data-source
SCHOOL_MASTER_SHARE_CREDENTIALS_VERSION=1
SCHOOL_MASTER_ENDPOINT=https://io-datasharing-stg.unitst.org
SCHOOL_MASTER_BEARER_TOKEN=
SCHOOL_MASTER_EXPIRATION_TIME=
SCHOOL_MASTER_COUNTRY_EXCLUSION_LIST=ZCDF

QOS_SHARE_NAME=gold
QOS_SCHEMA_NAME=qos
QOS_SHARE_CREDENTIALS_VERSION=1
QOS_ENDPOINT=https://io-datasharing-stg.unitst.org
QOS_BEARER_TOKEN=
QOS_EXPIRATION_TIME=
QOS_COUNTRY_EXCLUSION_LIST=MNG

CORS_ALLOW_ORIGINS=http://localhost:9500,*
INVALIDATE_CACHE_HARD=true

CACHE_CONTROL_MAX_AGE_FOR_FE=14400

API_KEY_ADMIN_DASHBOARD_URL=http://localhost:9500/admin/api-keys
13 changes: 13 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
max-line-length = 120
max-complexity = 30
exclude = proco_data_migrations, migrations, config/settings, manage.py, Exceptions.py, venv, dailycheckapp_contact, realtime_dailycheckapp, realtime_unicef
ignore =
; PyFlakes errors
; F405 name may be undefined, or defined from star imports: module
F405
W503
S105
E800
N400

9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
ignore:
- dependency-name: "Django"
versions: ">=3"
37 changes: 37 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and Push Docker image

on:
push:
branches: [ "feature/ci_backend" ]
env:
dockerfilePath: './Dockerfile'
app: 'project-connect-api-v2'
tag: ${{ github.run_id }}
pythonVersion: '3.8'
jobs:
build:
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}

- name: 'Docker Login'
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ${{ env.dockerfilePath }}
push: true
tags: ${{ secrets.REGISTRY_LOGIN_SERVER }}/${{ env.app }}:${{ env.tag }}
36 changes: 36 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Django CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build_test_deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2

# Pull the latest image to build, and avoid caching pull-only images.
# (docker pull is faster than caching in most cases.)
- run: docker-compose -f docker/docker-compose.test.yml pull

- name: Pull docker image
run: |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }}
docker pull rttest/project-connect-api:prod
- name: Build docker image
run: docker build -f docker/Dockerfile . -t proco_backend

- name: Run tests
run: docker-compose -f docker/docker-compose.test.yml up --abort-on-container-exit

- name: Push to Docker Hub
if: github.ref == 'refs/heads/master'
run: |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }}
docker tag proco_backend rttest/project-connect-api:prod
docker push rttest/project-connect-api:prod
89 changes: 89 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Created by .ignore support plugin (hsz.mobi)
# IntelliJ project files
.idea
.vscode
*.iml
out
gen

### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
config/settings/env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Celery
celerybeat-schedule
celerybeat-schedule.db
celerybeat.pid

# SublimeText
*.sublime-*

# Private keys
*.pem

# Env config file
env.config
.env
/config/settings/custom.py
/media/
rabbitmq


postgres_data/
docker/docker-compose.dev.yml
10 changes: 10 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[settings]
line_length=120
multi_line_output=3
balanced_wrapping=true
skip=migrations,deployer,wsgi.py,proco_data_migrations,config/settings,manage.py,Exceptions.py,venv
include_trailing_comma=true

known_django=django
known_rest=rest_framework
sections=FUTURE,STDLIB,DJANGO,REST,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
61 changes: 61 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
FROM python:3.8-buster

# Install dependencies
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
build-essential \
libcurl4-openssl-dev \
libjpeg-dev \
vim \
ntp \
libpq-dev
RUN apt-get install -y --no-install-recommends \
git-core
RUN apt-get install -y --no-install-recommends \
postgresql-client \
libpq-dev \
python-psycopg2
RUN apt-get install -y --no-install-recommends \
python-gdal \
gdal-bin \
libgdal-dev \
libgdal20 \
libxml2-dev \
libxslt-dev \
xmlsec1

RUN pip install --upgrade \
setuptools \
pip \
wheel \
pipenv

# ssh
ENV SSH_PASSWD "root:Docker!"
RUN apt-get update \
&& apt-get install -y --no-install-recommends dialog \
&& apt-get update \
&& apt-get install -y --no-install-recommends openssh-server \
&& echo "$SSH_PASSWD" | chpasswd

COPY sshd_config /etc/ssh/

# python app
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /code

RUN mkdir /code

ADD Pipfile /code/Pipfile
ADD Pipfile.lock /code/Pipfile.lock

WORKDIR /code/

# todo: try to figure out how we can test using dev packages and exclude them from prod build at the same time...
RUN pipenv install --ignore-pipfile --dev

ADD . /code/
# cleanup env files if any
RUN find . -type f -name '.env' -delete

EXPOSE 8000 2222
Loading

0 comments on commit d90e916

Please sign in to comment.