From d0d822b8f4b38a530fa99c2ba8c9eb1c2da8cd5c Mon Sep 17 00:00:00 2001 From: Aarni Halinen Date: Tue, 8 Oct 2019 00:22:03 +0300 Subject: [PATCH 1/2] Add network_mode host for DB access --- stack-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/stack-compose.yml b/stack-compose.yml index 169c098..723464d 100644 --- a/stack-compose.yml +++ b/stack-compose.yml @@ -4,6 +4,7 @@ services: image: registry.gitlab.com/sahkoinsinoorikilta/vtmk/web2.0-backend:latest ports: - 8000:8000 + network_mode: host environment: SECRET_KEY: /run/secrets/DJANGO_SECRET_KEY TG_BOT_TOKEN: /run/secrets/DJANGO_TG_BOT_TOKEN From d17d1fb1b7018526cb10e97ef9e7da14e7f86c74 Mon Sep 17 00:00:00 2001 From: Aarni Halinen Date: Tue, 8 Oct 2019 00:29:20 +0300 Subject: [PATCH 2/2] Add entrypoint script --- Dockerfile.prod | 8 ++++++-- production_entrypoint.sh | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 production_entrypoint.sh diff --git a/Dockerfile.prod b/Dockerfile.prod index 5b4f511..060f380 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -18,5 +18,9 @@ RUN apk add --no-cache --virtual .build-deps python3-dev build-base linux-header && pip install -r requirements.production.txt \ && apk del .build-deps -ENTRYPOINT ["sh", "-c", "echo 'Django running on http://localhost:8000 in production mode' \ - && gunicorn -w 4 -b 0.0.0.0:8000 sikweb.wsgi"] +RUN python manage.py collectstatic --noinput + +# run migrate +# python manage.py migrate --noinput + +ENTRYPOINT ["sh", "-c", "./production_entrypoint.sh"] diff --git a/production_entrypoint.sh b/production_entrypoint.sh new file mode 100644 index 0000000..bce7881 --- /dev/null +++ b/production_entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Collect static files +echo "Collect static files" +python manage.py collectstatic --noinput + +# Apply database migrations +echo "Apply database migrations" +python manage.py migrate + +# Start server +echo "Django running on http://localhost:8000 in production mode" +gunicorn -w 4 -b 0.0.0.0:8000 sikweb.wsgi \ No newline at end of file