-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
40 lines (29 loc) · 1.06 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
FROM python:3.7-slim
MAINTAINER tinolin2010@gmail.com
WORKDIR /usr/src/app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
LC_ALL=C.UTF-8 \
HOST=0.0.0.0 \
PORT=80 \
WORKERS=3 \
USER=admin \
PSWD=admin
COPY requirements.txt /usr/src/app
RUN pip install --upgrade pip && \
pip install django gunicorn whitenoise && \
pip install --no-cache-dir -r requirements.txt
ADD . /usr/src/app
RUN python manage.py makemigrations --noinput && \
python manage.py migrate --noinput
RUN find . -name "settings.py" -exec sed -i \
"/django.middleware.clickjacking.XFrameOptionsMiddleware/ i \
\ \ \ 'whitenoise.middleware.WhiteNoiseMiddleware'\," {} +
RUN echo "from django.contrib.auth.models import User;\
User.objects.create_superuser('${USER}', '', '${PSWD}')"\
| python manage.py shell
EXPOSE ${PORT}
ARG PROJECT_NAME
RUN if [ -z "${PROJECT_NAME}" ]; then echo "NOT SET - ERROR"; exit 1; else : ; fi
ENV PROJECT_NAME=${PROJECT_NAME}
CMD exec gunicorn ${PROJECT_NAME}.wsgi:application --bind ${HOST}:${PORT} --workers ${WORKERS}