add refined dockerfile with gunicorn
This commit is contained in:
parent
f97202869c
commit
70ccad1d46
21
Dockerfile
21
Dockerfile
|
@ -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"]
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
django>=3.0
|
django>=3.0
|
||||||
celery>=4.4
|
celery>=4.4
|
||||||
|
gunicorn>=20
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue