forked from City-of-Turku/tunnistamo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
88 lines (70 loc) · 2.52 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
# =========================================================
FROM helsinkitest/python-node:3.6-10-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 \
pkg-config \
git \
curl \
libpq-dev \
build-essential
WORKDIR /app
COPY requirements.txt /app/requirements.txt
COPY package.json /app/package.json
RUN pip install -U pip \
&& pip install --no-cache-dir -r /app/requirements.txt
RUN npm install
COPY . /app/
RUN python manage.py collectstatic --noinput
# ===========================================
FROM helsinkitest/python:3.6-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 \
netcat \
nodejs \
pkg-config \
&& pip install -U pip \
&& pip install --no-cache-dir -r /app/requirements.txt \
&& pip install --no-cache-dir -r /app/requirements-prod.txt \
&& apt-cleanup.sh build-essential pkg-config git
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 NODE_MODULES_ROOT /var/tunnistamo/node_modules
COPY --from=staticbuilder --chown=appuser:appuser /app/static /var/tunnistamo/static
COPY --from=staticbuilder --chown=appuser:appuser /app/node_modules /var/tunnistamo/node_modules
# =========================
FROM appbase as development
# =========================
COPY --chown=appuser:appuser requirements-dev.txt /app/requirements-dev.txt
RUN pip install --no-cache-dir -r /app/requirements-dev.txt \
&& pip install --no-cache-dir prequ
ENV DEV_SERVER=1
COPY --chown=appuser:appuser . /app/
USER appuser
EXPOSE 8000/tcp
# ==========================
FROM appbase as production
# ==========================
COPY --chown=appuser:appuser . /app/
USER appuser
EXPOSE 8000/tcp