-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
56 lines (40 loc) · 1.38 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Please remember to rename django_heroku to your project directory name
FROM node:14-stretch-slim as frontend-builder
WORKDIR /app/frontend
COPY ./frontend/package.json /app/frontend
COPY ./frontend/package-lock.json /app/frontend
ENV PATH ./node_modules/.bin/:$PATH
RUN npm ci
COPY ./frontend .
RUN npm run build
#################################################################################
FROM python:3.10-slim-buster
WORKDIR /app
ENV PYTHONUNBUFFERED=1 \
PYTHONPATH=/app \
DJANGO_SETTINGS_MODULE=django_heroku.settings \
PORT=8000 \
WEB_CONCURRENCY=3
# Install system packages required by Wagtail and Django.
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
build-essential curl \
libpq-dev \
libmariadbclient-dev \
libjpeg62-turbo-dev \
zlib1g-dev \
libwebp-dev \
&& rm -rf /var/lib/apt/lists/*
RUN addgroup --system django \
&& adduser --system --ingroup django django
# Requirements are installed here to ensure they will be cached.
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
# Copy project code
COPY . .
COPY --from=frontend-builder /app/frontend/build /app/frontend/build
RUN python manage.py collectstatic --noinput --clear
# Run as non-root user
RUN chown -R django:django /app
USER django
# Run application
CMD gunicorn django_heroku.wsgi:application