This repository has been archived by the owner on Jun 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
81 lines (61 loc) · 1.74 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Stage 1 - Compile needed python dependencies
FROM python:3.7-alpine AS build
RUN apk --no-cache add \
gcc \
musl-dev \
pcre-dev \
linux-headers \
postgresql-dev \
python3-dev \
# lxml dependencies
libxslt-dev
WORKDIR /app
COPY ./requirements /app/requirements
RUN pip install pip setuptools==47.1.1
RUN pip install -r requirements/production.txt
# Stage 2 - build frontend
FROM mhart/alpine-node:10 AS frontend-build
WORKDIR /app
COPY ./*.json /app/
RUN npm install
COPY ./Gulpfile.js /app/
COPY ./build /app/build/
COPY src/verzoeken/sass/ /app/src/verzoeken/sass/
RUN npm run build
# Stage 3 - Build docker image suitable for execution and deployment
FROM python:3.7-alpine AS production
RUN apk --no-cache add \
ca-certificates \
mailcap \
musl \
pcre \
postgresql \
# lxml dependencies
libxslt \
# pillow dependencies
jpeg \
openjpeg \
zlib
# Stage 3.1 - Set up dependencies
COPY --from=build /usr/local/lib/python3.7 /usr/local/lib/python3.7
COPY --from=build /usr/local/bin/uwsgi /usr/local/bin/uwsgi
# required for fonts,styles etc.
COPY --from=frontend-build /app/node_modules/font-awesome /app/node_modules/font-awesome
# Stage 3.2 - Copy source code
WORKDIR /app
COPY ./bin/docker_start.sh /start.sh
RUN mkdir /app/log
COPY --from=frontend-build /app/src/verzoeken/static/css /app/src/verzoeken/static/css
COPY ./src /app/src
RUN adduser -D -H -u 1000 user
RUN chown -R user /app
# drop privileges
USER user
ARG COMMIT_HASH
ENV GIT_SHA=${COMMIT_HASH}
ENV DJANGO_SETTINGS_MODULE=verzoeken.conf.docker
ARG SECRET_KEY=dummy
# Run collectstatic, so the result is already included in the image
RUN python src/manage.py collectstatic --noinput
EXPOSE 8000
CMD ["/start.sh"]