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 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