-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile_django
43 lines (28 loc) · 1.21 KB
/
Dockerfile_django
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
41
42
43
FROM python:3.11 as build-stage
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
WORKDIR /workdir
COPY . .
ENV DJANGO_ENV=production
RUN python manage.py collectstatic --noinput -v2
FROM python:3.11
RUN apt-get update && apt-get install -y --no-install-recommends \
gettext \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -r runner && useradd --no-log-init -r -g runner runner
# Must match the settings.DATABASES default value.
RUN mkdir -p /data/db && chown -R runner:runner /data/db
# Must match the settings.MEDIA_ROOT default value.
RUN mkdir -p /data/media && chown -R runner:runner /data/media
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
WORKDIR /workdir
USER runner:runner
COPY --chown=runner:runner . .
# Django needs a copy of the staticfiles.json manifest file.
COPY --from=build-stage --chown=runner:runner /workdir/static/staticfiles.json /workdir/static/staticfiles.json
ENV DJANGO_ENV=production
ENV WEB_CONCURRENCY=2
RUN python manage.py compilemessages
EXPOSE 8000
CMD ["gunicorn", "core.wsgi", "--bind", "0.0.0.0:8000", "--worker-tmp-dir", "/dev/shm", "--threads", "2", "--name", "cove"]