-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
78 lines (60 loc) · 2.34 KB
/
Copy pathDockerfile
File metadata and controls
78 lines (60 loc) · 2.34 KB
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
# ==============================
FROM registry.access.redhat.com/ubi9/python-312 AS appbase
# ==============================
# Branch or tag used to pull python-uwsgi-common.
ARG UWSGI_COMMON_REF="main"
USER root
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY requirements.txt .
COPY requirements-prod.txt .
RUN dnf update -y \
&& dnf install -y \
nmap-ncat \
gettext \
&& pip install --only-binary :all: -U pip setuptools wheel \
&& pip install --require-hashes --no-deps --no-cache-dir -r requirements.txt \
&& pip install --require-hashes --no-deps --no-cache-dir -r requirements-prod.txt \
&& dnf clean all
# Build and copy specific python-uwsgi-common files.
ADD https://github.com/City-of-Helsinki/python-uwsgi-common/archive/"${UWSGI_COMMON_REF}".tar.gz /usr/src/
RUN mkdir -p /usr/src/python-uwsgi-common \
&& tar --strip-components=1 -xzf /usr/src/"${UWSGI_COMMON_REF}".tar.gz -C /usr/src/python-uwsgi-common \
&& mkdir /etc/uwsgi \
&& cp /usr/src/python-uwsgi-common/uwsgi-base.ini /etc/uwsgi/ \
&& uwsgi --build-plugin /usr/src/python-uwsgi-common \
&& rm -rf /usr/src/"${UWSGI_COMMON_REF}".tar.gz \
&& rm -rf /usr/src/python-uwsgi-common \
&& uwsgi --build-plugin https://github.com/City-of-Helsinki/uwsgi-sentry \
&& mkdir -p /usr/local/lib/uwsgi/plugins \
&& mv sentry_plugin.so /usr/local/lib/uwsgi/plugins
ENTRYPOINT ["/app/.docker/docker-entrypoint.sh"]
# ==============================
FROM appbase AS development
# ==============================
COPY requirements-dev.txt .
RUN pip install --require-hashes --no-deps --no-cache-dir -r requirements-dev.txt
ENV DEV_SERVER=True
ENV PIP_TOOLS_CACHE_DIR="/tmp/pip-tools-cache"
RUN groupadd -g 1000 appuser \
&& useradd -u 1000 -g appuser -ms /bin/bash appuser \
&& chown -R appuser:root /app
COPY --chown=appuser:root . .
USER appuser
EXPOSE 8000/tcp
# ==============================
FROM appbase AS staticbuilder
# ==============================
ENV STATIC_ROOT="/app/static"
COPY . .
RUN mkdir -p tirehtoori/static \
&& SECRET_KEY="only-used-for-collectstatic" ENABLE_ADMIN_APP="True" \
python manage.py collectstatic --noinput
# ==============================
FROM appbase AS production
# ==============================
COPY --from=staticbuilder /app/static /app/static
COPY . .
USER default
EXPOSE 8000/tcp