-
Notifications
You must be signed in to change notification settings - Fork 24
/
Dockerfile
99 lines (80 loc) · 2.82 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# =========================================================
FROM helsinkitest/python-node:3.9-14-slim AS staticbuilder
# ---------------------------------------------------------
# Stage for building static files for
# the project. Installs Node as that
# is required for compiling SCSS files.
# =========================================================
RUN apt-install.sh \
libxmlsec1-dev \
libxml2-dev \
libxslt-dev \
zlib1g-dev \
pkg-config \
git \
curl \
libpq-dev \
build-essential
WORKDIR /app
COPY requirements.txt /app/requirements.txt
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json
RUN pip install -U pip setuptools wheel \
&& pip install --no-cache-dir -r /app/requirements.txt
RUN npm install
COPY . /app/
RUN python manage.py compilescss \
&& python manage.py collectstatic --noinput
# ===========================================
FROM helsinkitest/python:3.9-slim AS appbase
# ===========================================
WORKDIR /app
COPY --chown=appuser:appuser requirements.txt /app/requirements.txt
COPY --chown=appuser:appuser requirements-prod.txt /app/requirements-prod.txt
# Install main project dependencies and clean up
# Note that production dependencies are installed here as well since
# that is the default state of the image and development stages are
# just extras.
RUN apt-install.sh \
build-essential \
libpq-dev \
gettext \
git \
libxmlsec1-dev \
libxml2-dev \
libxslt-dev \
zlib1g-dev \
netcat-openbsd \
pkg-config \
&& pip install -U pip setuptools wheel \
&& pip install --no-cache-dir -r /app/requirements.txt \
&& UWSGI_PROFILE_OVERRIDE="ssl=false" pip install --no-cache-dir -r /app/requirements-prod.txt \
&& apt-cleanup.sh build-essential pkg-config
COPY docker-entrypoint.sh /app
ENTRYPOINT ["./docker-entrypoint.sh"]
# Store static files under /var to not conflict with development volume mount
ENV STATIC_ROOT /var/tunnistamo/static
ENV MEDIA_ROOT /var/tunnistamo/media
ENV NODE_MODULES_ROOT /var/tunnistamo/node_modules
ENV APP_URL_PATH /
COPY --from=staticbuilder --chown=appuser:appuser /app/static /var/tunnistamo/static
COPY --from=staticbuilder --chown=appuser:appuser /app/node_modules /var/tunnistamo/node_modules
COPY --chown=appuser:appuser . /app/
USER appuser
RUN python manage.py compilemessages
# =========================
FROM appbase AS development
# =========================
USER root
RUN apt-install.sh build-essential
USER appuser
COPY --chown=appuser:appuser requirements-dev.txt /app/requirements-dev.txt
RUN pip install --no-cache-dir -r /app/requirements-dev.txt
ENV DEV_SERVER=1
USER appuser
EXPOSE 8000/tcp
# ==========================
FROM appbase AS production
# ==========================
USER appuser
EXPOSE 8000/tcp