Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize kpi #41

Open
wants to merge 3 commits into
base: ona-custom-changes
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM nikolaik/python-nodejs:python3.8-nodejs10
ARG additional_pip_packages=pyjwt

ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=en_US.UTF-8
Expand Down Expand Up @@ -76,6 +77,7 @@ RUN pip install --quiet --upgrade pip && \
pip install --quiet pip-tools
COPY ./dependencies/pip/external_services.txt /srv/tmp/pip_dependencies.txt
RUN pip-sync /srv/tmp/pip_dependencies.txt 1>/dev/null && \
pip install ${additional_pip_packages} && \
rm -rf ~/.cache/pip

###########################
Expand Down
41 changes: 41 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '2.2'

services:
kpi_db:
image: postgis/postgis:9.6-3.0
environment:
- POSTGRES_PASSWORD=kpi
- POSTGRES_USER=kpi
- POSTGRES_DB=kpi
volumes:
# One level above the code to prevent having to move or delete
# it everytime we rebuild.
- ../.kpi_db:/var/lib/postgresql/data
onadata_db:
image: postgis/postgis:9.6-3.0
environment:
- POSTGRES_PASSWORD=onadata
- POSTGRES_USER=onadata
- POSTGRES_DB=onadata
volumes:
# One level above the code to prevent having to move or delete
# it everytime we rebuild.
- ../.onadata_db:/var/lib/postgresql/data
web:
build:
context: .
dockerfile: Dockerfile
image: kpi:latest
ports:
- "8000:8000"
depends_on:
- kpi_db
- onadata_db
environment:
- DATABASE_URL=postgres://kpi_db:5432/kpi
- DJANGO_SETTINGS_MODULE=kobo.settings.local_settings
- KPI_SRC_DIR=/srv/src/kpi
- KPI_LOGS_DIR=/srv/logs
- KPI_PREFIX=kpi
volumes:
- .:/srv/src/kpi
11 changes: 11 additions & 0 deletions docker/init.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ set -e

source /etc/profile

# Have web service wait until db services are ready to accept connections
sleep 1

echo 'KoBoForm initializing...'

cd "${KPI_SRC_DIR}"
Expand All @@ -18,7 +21,10 @@ fi
/bin/bash "${INIT_PATH}/wait_for_mongo.bash"
/bin/bash "${INIT_PATH}/wait_for_postgres.bash"


echo 'Running migrations...'
python manage.py makemigrations --merge --noinput
python manage.py makemigrations --noinput
python manage.py migrate --noinput

echo 'Creating superuser...'
Expand Down Expand Up @@ -65,4 +71,9 @@ rm -rf /tmp/celery*.pid

echo 'KoBoForm initialization completed.'

# Have kpi service accessible on the browser
source /opt/venv/bin/activate
cd /srv/src/kpi
python manage.py runserver 0.0.0.0:8000

exec /usr/bin/runsvdir /etc/service