From bd0bd78c5dc3da979b65589c1e3920237423749b Mon Sep 17 00:00:00 2001 From: WinnyTroy Date: Tue, 4 May 2021 17:40:04 +0300 Subject: [PATCH] Include docker compose to handle kpi db services. Pip install jwt package within kpi web docker container. Comment out mongo and postgres db wait docker scripts --- Dockerfile | 2 +- docker-compose.yml | 37 +++++++++++++++++++++++++++++++++++++ docker/init.bash | 4 ++-- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index cce17c9b78..9a9becd6f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,7 +73,7 @@ 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 --quiet pip-tools && pip install jwt COPY ./dependencies/pip/external_services.txt /srv/tmp/pip_dependencies.txt RUN pip-sync /srv/tmp/pip_dependencies.txt 1>/dev/null && \ rm -rf ~/.cache/pip diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..f5d073e0ee --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ +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. + - /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. + - /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://db:5432/kpi + volumes: + - .:/srv/src/kpi diff --git a/docker/init.bash b/docker/init.bash index 1e6e865a71..cc1f245854 100755 --- a/docker/init.bash +++ b/docker/init.bash @@ -15,8 +15,8 @@ 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 migrate --noinput