add refined dockerfile with gunicorn

This commit is contained in:
Jan Koppe 2020-04-20 18:56:29 +02:00
parent f97202869c
commit 70ccad1d46
Signed by: thunfisch
GPG Key ID: BE935B0735A2129B
3 changed files with 40 additions and 1 deletions

View File

@ -1,4 +1,23 @@
FROM python:3.8-alpine FROM python:3.8-alpine
WORKDIR /app WORKDIR /app
ADD . /app
# set env
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
EXPOSE 8000
# psycopg2 dependencies
RUN apk update \
&& apk add postgresql-dev gcc python3-dev musl-dev
# install dependencies
ADD ./requirements.txt .
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
# add user
RUN addgroup -S portier && adduser -S portier -G portier
# add code
ADD --chown=portier:portier . /app
CMD ["/app/start.sh", "migrate_start"]

View File

@ -1,2 +1,3 @@
django>=3.0 django>=3.0
celery>=4.4 celery>=4.4
gunicorn>=20

19
start.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
migrate() {
python manage.py makemigrations
python manage.py migrate
}
case $1 in
"create_superuser" )
python manage.py createsuperuser --no-input --username "${ADMIN_USER:-admin}" --email "${ADMIN_EMAIL:-post@chaoswest.tv}"
;;
"migrate_start" )
migrate
gunicorn -w 4 --bind 0.0.0.0:${EXPOSE_PORT:-8000} portier.wsgi
;;
"only_start" )
gunicorn -w 4 --bind 0.0.0.0:${EXPOSE_PORT:-8000} portier.wsgi
;;
esac