-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (57 loc) · 2.85 KB
/
Copy pathDockerfile
File metadata and controls
80 lines (57 loc) · 2.85 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
79
80
# ==============================
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
RUN dnf --disableplugin subscription-manager -y --allowerasing update \
&& dnf --disableplugin subscription-manager -y install pcre-devel nmap-ncat \
&& dnf --disableplugin subscription-manager -y clean all
COPY --chmod=0550 --chown=1000:0 scripts /scripts
ENV PATH="/scripts:${PATH}"
RUN setup_user.sh
RUN mkdir /app && chown -R 1000:0 /app
## Need to set the permissions beforehand for the Attachment directory
## https://github.com/docker/compose/issues/3270#issuecomment-363478501
RUN mkdir -p /var/media && chown -R 1000:0 /var/media && chmod g=u -R /var/media
RUN mkdir -p /var/static && chown -R 1000:0 /var/static && chmod g=u -R /var/static
RUN mkdir -p /usr/local/lib/uwsgi/plugins && chown -R 1000:0 /usr/local/lib/uwsgi/plugins \
&& chmod g=u -R /usr/local/lib/uwsgi/plugins
WORKDIR /app
COPY --chmod=0440 --chown=1000:0 requirements.txt /app/requirements.txt
RUN pip install -U pip setuptools wheel \
&& pip install --no-cache-dir -r /app/requirements.txt
# Build and copy specific python-uwsgi-common files.
ADD --chmod=0440 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 && \
uwsgi --build-plugin https://github.com/City-of-Helsinki/uwsgi-sentry && \
mv sentry_plugin.so /usr/local/lib/uwsgi/plugins/
USER 1000
COPY --chmod=0555 --chown=1000:0 docker-entrypoint.sh /entrypoint/docker-entrypoint.sh
ENTRYPOINT ["/entrypoint/docker-entrypoint.sh"]
EXPOSE 8000/tcp
# ==============================
FROM appbase AS development
# ==============================
COPY --chmod=0440 --chown=1000:0 requirements-dev.txt ./requirements-dev.txt
RUN pip install --no-cache-dir -r ./requirements-dev.txt
ENV DEV_SERVER=1
COPY --chmod=0750 --chown=1000:0 . /app/
# ==============================
FROM appbase AS staticbuilder
# ==============================
ENV STATIC_ROOT=/var/static
COPY --chmod=0555 --chown=1000:0 . /app/
RUN SECRET_KEY="only-used-for-collectstatic" python manage.py collectstatic --noinput
# ==============================
FROM appbase AS production
# ==============================
# fatal: detected dubious ownership in repository at '/app'
RUN git config --global --add safe.directory /app
COPY --from=staticbuilder --chmod=0555 --chown=1000:0 /var/static /var/static
COPY --chmod=0555 --chown=1000:0 . /app/