-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (44 loc) · 1.93 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (44 loc) · 1.93 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
# ==============================
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
RUN mkdir /entrypoint
# chmod=755 = rwxr-xr-x i.e. owner can read, write and execute, group and others can read and execute.
#
# Related to SonarCloud security hotspot docker:S6470 i.e.
# "Recursively copying context directories is security-sensitive" i.e.
# https://rules.sonarsource.com/docker/RSPEC-6470/
# see .dockerignore for info on what is not copied here:
COPY --chown=root:root --chmod=755 . /app/
RUN dnf update -y \
&& dnf install -y nmap-ncat \
&& pip install --upgrade pip setuptools wheel \
&& pip install --no-cache-dir -r /app/requirements.txt \
&& uwsgi --build-plugin https://github.com/City-of-Helsinki/uwsgi-sentry \
&& 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 && \
cp /usr/src/python-uwsgi-common/uwsgi-base.ini /app && \
uwsgi --build-plugin /usr/src/python-uwsgi-common && \
rm -rf /usr/src/${UWSGI_COMMON_REF}.tar.gz && \
rm -rf /usr/src/python-uwsgi-common
COPY --chown=root:root --chmod=755 docker-entrypoint.sh /entrypoint/docker-entrypoint.sh
ENTRYPOINT ["/entrypoint/docker-entrypoint.sh"]
# ==============================
FROM appbase AS development
# ==============================
RUN pip install --no-cache-dir -r /app/requirements-dev.txt
ENV DEV_SERVER=1
USER default
EXPOSE 8081/tcp
# ==============================
FROM appbase AS production
# ==============================
RUN SECRET_KEY="only-used-for-collectstatic" python manage.py collectstatic
USER default
EXPOSE 8000/tcp