diff --git a/Dockerfile b/Dockerfile index 9a9becd6f7..eed720bd5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -73,9 +74,10 @@ COPY . "${KPI_SRC_DIR}" RUN virtualenv "$VIRTUAL_ENV" ENV PATH="$VIRTUAL_ENV/bin:$PATH" RUN pip install --quiet --upgrade pip && \ - pip install --quiet pip-tools && pip install jwt + 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 ########################### diff --git a/docker-compose.yml b/docker-compose.yml index f5d073e0ee..2e727074cd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: volumes: # One level above the code to prevent having to move or delete # it everytime we rebuild. - - /var/lib/postgresql/data + - ../.kpi_db:/var/lib/postgresql/data onadata_db: image: postgis/postgis:9.6-3.0 environment: @@ -20,7 +20,7 @@ services: volumes: # One level above the code to prevent having to move or delete # it everytime we rebuild. - - /var/lib/postgresql/data + - ../.onadata_db:/var/lib/postgresql/data web: build: context: . @@ -32,6 +32,10 @@ services: - kpi_db - onadata_db environment: - - DATABASE_URL=postgres://db:5432/kpi + - 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 + - .:/srv/src/kpi diff --git a/docker/init.bash b/docker/init.bash index cc1f245854..542efaa42f 100755 --- a/docker/init.bash +++ b/docker/init.bash @@ -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}" @@ -15,10 +18,13 @@ fi # Wait for databases to be up & running before going further -# /bin/bash "${INIT_PATH}/wait_for_mongo.bash" -# /bin/bash "${INIT_PATH}/wait_for_postgres.bash" +/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...' @@ -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