-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
781 changed files
with
151,456 additions
and
31,810 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.git | ||
*.log | ||
.Trashes | ||
*.sqlite3 | ||
tmp | ||
.env | ||
mics/localsettings.py | ||
*.md | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# Default settings okay to test the docker setup. | ||
# You may want to define environment variables on your bash profile instead in production environment | ||
# As per docker behavior, environment variables defined on you bash profile overrides these settings. | ||
# Pls be sure to update these when deploying to your environment | ||
|
||
|
||
# =========== Database settings ===========# | ||
|
||
# uSurvey Database | ||
USURVEY_DB=usurvey | ||
|
||
# DB user | ||
USURVEY_DB_USER=usurvey | ||
|
||
# DB Password | ||
USURVEY_DB_PASS=usurvey1234 | ||
|
||
#Database port exposed to host machine | ||
USURVEY_DB_PORT=5430 | ||
|
||
# Path where database file would be stored on host machine (created if it does not exist) | ||
# You may leave this setting unchanged unless if required. | ||
POSTGRES_DATA_PATH=/opt/db/data/psql | ||
|
||
|
||
#=============== Redis Settings ================= # | ||
USURVEY_REDIS_PORT=6378 | ||
|
||
|
||
# ============= Email settings ============= # | ||
# The following are email settings for uSurvey. Be sure to enter the correct parameters for email to work. | ||
EMAIL_HOST=smtp.gmail.com | ||
EMAIL_PORT=587 | ||
EMAIL_HOST_USER= | ||
EMAIL_HOST_PASSWORD= | ||
# Default email sender defaults to $EMAIL_HOST_USER is value is not set. | ||
DEFAULT_EMAIL_SENDER= | ||
|
||
|
||
|
||
# ========== map settings ================== # | ||
|
||
# uSurvey must be made aware of the shape file to use. The shape file is expected to contain json data. | ||
# Current defaults are set to values which come shipped with the application (Uganda) | ||
# The country Geo Json shape file should be similar to what is available on https://mapzen.com/data/borders/ | ||
# The expected GeoJson files should be compatible with specification http://geojson.org/geojson-spec.html | ||
# Note that for files obtained from https://mapzen.com/data/borders/, \ | ||
# you need to select the exact shape file which captures administrative level you want to display on the map for your country | ||
# From experience, loading admin_level_4.geojson should be good enough (however choose as appropriate). | ||
# If nothing comes out from admin_level_4.geojson, it might be that it's not captured for your country | ||
# In that case, try the file admin_level_3.geojson | ||
# SHAPE_FILE_URI is the URI for uSurvey to download the maps geo json file. You can specify a URL publicly available. | ||
# uSurvey performs a HTTP(s) GET to fetch this GeoJson file as per specified URI. | ||
# As an alternative to using a location out side the uSurvey, | ||
# You can copy desired the shape file into ._docker_mapf directory which is in the project directory | ||
# To do this, first rename the file to country_shape_file.json. | ||
# Then copy this file into ._docker_mapf in the project directory | ||
# On linux: `cp country_shape_file.json ._docker_mapf/` | ||
# This is all it takes! | ||
# Restart the container for it to take effect: | ||
# docker-compose down | ||
# docker-compose up -d | ||
SHAPE_FILE_URI=/static/map_resources/country_shape_file.json | ||
|
||
# field in the geojson referring to the field name holding each admin division's polygon | ||
# Ordinarily give defaults should work for https://mapzen.com/data/borders/ | ||
# If this doesn't, you might have to check the property name your admin divisions name in the geojson file. | ||
SHAPE_FILE_LOC_FIELD=name:en | ||
|
||
# field refers to the alternative name to look for the polygon in addition to SHAPE_FILE_LOC_FIELD | ||
# Ordinarily give defaults should work for https://mapzen.com/data/borders/ | ||
# If this doesn't, you might have to check the property name your admin divisions name in the geojson file. | ||
SHAPE_FILE_LOC_ALT_FIELD=name | ||
|
||
# This setting is used to tell uSurvey the administrative division level to look for names to match against names \ | ||
# derived at field SHAPE_FILE_LOC_FIELD or SHAPE_FILE_LOC_ALT_FIELD in the map. | ||
# This enables uSurvey present the data results at that administrative level to the map. | ||
# Current default is first administrative level immediately under the country as imported using import locations command | ||
# 0 for country level, 1 first level below country, 2 for second level etc. | ||
MAP_ADMIN_LEVEL=1 | ||
|
||
# This setting controls the zoom level of the map. | ||
# Adjust this value to increase or reduce the zoom level on map as desired | ||
MAP_ZOOM_LEVEL=7 | ||
|
||
|
||
# ==================== GUNICORN settings ================== # | ||
|
||
# This is the port which is exposed to the host to access uSurvey application | ||
USURVEY_APP_PORT=8071 | ||
|
||
# This maps directly to --workers settings of gunicorn | ||
USURVEY_APP_WORKERS=8 | ||
|
||
# maps to --max-requests settings of gunicorn | ||
USURVEY_APP_MAX_REQUESTS=1000 | ||
|
||
# Application time out gunicorn's --timeout setting | ||
USURVEY_APP_TIMEOUT=120 | ||
|
||
|
||
# ===================== COUNTRY settings ==================== # | ||
|
||
COUNTRY=Uganda | ||
|
||
TIME_ZONE=Africa/Kampala | ||
COUNTRY=sweden | ||
COUNTRY=sweden | ||
COUNTRY=sweden | ||
COUNTRY=sweden | ||
COUNTRY=kazakhstan | ||
COUNTRY=kazakhstan | ||
COUNTRY=kazakhstan | ||
COUNTRY=kazakhstan | ||
COUNTRY=kazakhstan | ||
COUNTRY=kazakhstan | ||
COUNTRY=kazakhstan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
FROM python:2.7-alpine | ||
|
||
# Copy in your requirements file | ||
ADD pip-freeze.txt /pip-freeze.txt | ||
|
||
# Install build deps, then run `pip install`, then remove unneeded build deps all in a single step. Correct the path to your production requirements file, if needed. | ||
RUN set -ex \ | ||
&& apk add --update alpine-sdk --no-cache \ | ||
gcc \ | ||
make \ | ||
libc-dev \ | ||
musl-dev \ | ||
linux-headers \ | ||
pcre-dev \ | ||
libpq \ | ||
postgresql-dev \ | ||
git \ | ||
libxml2-dev \ | ||
libxslt-dev \ | ||
zlib-dev \ | ||
libffi-dev \ | ||
postgresql-client \ | ||
&& LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "pip install -U pip" \ | ||
&& LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "pip install -r /pip-freeze.txt" | ||
|
||
|
||
# Copy application code to the container | ||
RUN mkdir /src/ | ||
WORKDIR /src/ | ||
ADD . /src/ | ||
|
||
# create directory for odk files | ||
RUN mkdir -p /src/files/submissions/ | ||
RUN mkdir -p /src/files/answerFiles/ | ||
|
||
# create log dir | ||
RUN mkdir /src/logs | ||
|
||
# setup the project | ||
RUN cp survey/interviewer_configs.py.example survey/interviewer_configs.py | ||
|
||
# Gunicorn will listen on this port | ||
EXPOSE 8080 8082 9001 | ||
|
||
RUN export LD_LIBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH | ||
|
||
# Add any custom, static environment variables needed by Django or your settings file here: | ||
ENV DJANGO_SETTINGS_MODULE=mics.settings | ||
|
||
RUN DATABASE_URL=none python manage.py collectstatic --noinput | ||
|
||
|
||
|
||
# Make entry point executable | ||
RUN chmod +x /src/docker_entrypoint.sh | ||
|
||
#define entry point | ||
ENTRYPOINT ["/src/docker_entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Country,State,District,Mandal,Village,EAName | ||
INDIA,ANDHRAPRADESH,PRAKASAM,MARKAPURAM,MARKAPURAM,MARKAPURAM | ||
INDIA,ANDHRAPRADESH,PRAKASAM,YERRRAGONDAPALEM,YERRAGONDAPALEM,YERRAGONDAPALEM | ||
INDIA,ANDHRAPRADESH,GUNTUR,GUNTUR,MACHERLA,MACHERLA | ||
INDIA,ANDHRAPRADESH,PRAKASAM,MARKAPURAM,DEVARAJUGATTU,DEVARAJUGATTU | ||
INDIA,TELANGANA,HYDERABAD,RANGAREDDY,KUKATPALLY,KUKATPALLY | ||
INDIA,TELANGANA,HYDERABAD,RANGAREDDY,NIJAMPET,NIJAMPET | ||
INDIA,TELANGANA,HYDERABAD,RANGAREDDY,BACHEPALLY,BACHEPALLY | ||
INDIA,TELANGANA,HYDERABAD,RANGAREDDY,LINGAMPALLY,LINGAMPALLY | ||
INDIA,TELANGANA,HYDERABAD,RANGAREDDY,MADHEENAGOODA,MADHEENAGOODA |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""See: https://github.com/evansd/whitenoise/issues/96""" | ||
|
||
from whitenoise.storage import CompressedManifestStaticFilesStorage | ||
|
||
|
||
class WhitenoiseErrorSquashingStorage(CompressedManifestStaticFilesStorage): | ||
|
||
def url(self, name, **kwargs): | ||
try: | ||
return super(WhitenoiseErrorSquashingStorage, self).url(name, **kwargs) | ||
except ValueError: | ||
return name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
version: '2' | ||
|
||
services: | ||
|
||
usurvey_app: | ||
environment: | ||
# pick db details from environment variables | ||
- DATABASE_URL=postgres://${USURVEY_DB_USER}:${USURVEY_DB_PASS}@db/${USURVEY_DB} | ||
- REDIS_HOST=redis_server | ||
- USURVEY_DB_HOST=db | ||
- USURVEY_DB | ||
- USURVEY_DB_USER | ||
- USURVEY_DB_PASS | ||
- EMAIL_HOST | ||
- EMAIL_PORT | ||
- EMAIL_HOST_USER | ||
- EMAIL_HOST_PASSWORD | ||
- DEFAULT_EMAIL_SENDER | ||
- SHAPE_FILE_URI | ||
- SHAPE_FILE_LOC_FIELD | ||
- SHAPE_FILE_LOC_ALT_FIELD | ||
- MAP_CENTER | ||
- MAP_ADMIN_LEVEL | ||
- MAP_ZOOM_LEVEL | ||
- COUNTRY | ||
- TIME_ZONE | ||
- USURVEY_SECRET_KEY | ||
|
||
image: antsmc2/usurvey | ||
command: gunicorn -b 0.0.0.0:3691 --workers=$USURVEY_APP_WORKERS --max-requests $USURVEY_APP_MAX_REQUESTS --timeout $USURVEY_APP_TIMEOUT mics.wsgi | ||
depends_on: | ||
- redis_server | ||
- db | ||
ports: | ||
- "$USURVEY_APP_PORT:3691" | ||
volumes: | ||
- ./._docker_mapf:/src/survey/static/map_resources | ||
- ./logs:/src/logs | ||
- ./files/answerFiles:/src/files/answerFiles | ||
- ./files/submissions:/src/files/submissions | ||
|
||
db: | ||
environment: | ||
# pls replace with your own values | ||
POSTGRES_DB: ${USURVEY_DB} | ||
POSTGRES_USER: ${USURVEY_DB_USER} | ||
POSTGRES_PASSWORD: ${USURVEY_DB_PASS} | ||
restart: always | ||
image: postgres:alpine | ||
ports: | ||
- "$USURVEY_DB_PORT:5432" | ||
volumes: | ||
- ${POSTGRES_DATA_PATH}:/var/lib/postgresql/data | ||
|
||
redis_server: | ||
restart: always | ||
image: redis:alpine | ||
ports: | ||
- "$USURVEY_REDIS_PORT:6379" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
until psql $DATABASE_URL -c '\l'; do | ||
>&2 echo "Postgres: $DATABASE_URL is unavailable - sleeping" | ||
sleep 1 | ||
done | ||
|
||
>&2 echo "Postgres is up - continuing" | ||
|
||
>&2 echo "checking migration settings: $DJANGO_MANAGEPY_MIGRATE" | ||
|
||
if [ "x$DJANGO_MANAGEPY_MIGRATE" = 'xon' ]; then | ||
>&2 echo "Running migrations. " | ||
python manage.py makemigrations | ||
python manage.py migrate --noinput | ||
fi | ||
|
||
if [ "x$DJANGO_CREATE_SUPER_USER" = 'xon' ]; then | ||
>&2 echo "creating superuser..." | ||
python manage.py createsuperuser | ||
fi | ||
|
||
exec "$@" | ||
|
Oops, something went wrong.