Skip to content

Commit 72fbcf1

Browse files
committed
feat(nginx): Make nginx Read-only-friendly
1 parent eb3c83a commit 72fbcf1

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Dockerfile.nginx-alpine

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,24 @@ COPY dojo/ ./dojo/
6464
RUN env DD_SECRET_KEY='.' DD_DJANGO_DEBUG_TOOLBAR_ENABLED=True python3 manage.py collectstatic --noinput --verbosity=2 && true
6565

6666
FROM nginx:1.29.1-alpine3.22@sha256:42a516af16b852e33b7682d5ef8acbd5d13fe08fecadc7ed98605ba5e3b26ab8
67-
ARG uid=1001
68-
ARG appuser=defectdojo
67+
ARG uid=101
68+
ARG gid=101
6969
COPY --from=collectstatic /app/static/ /usr/share/nginx/html/static/
7070
COPY wsgi_params nginx/nginx.conf nginx/nginx_TLS.conf /etc/nginx/
7171
COPY docker/entrypoint-nginx.sh /
7272
RUN \
73-
apk add --no-cache openssl && \
73+
apk add --no-cache openssl
74+
RUN \
7475
chmod -R g=u /var/cache/nginx && \
76+
chown -R ${uid}:${gid} /var/cache/nginx && \
7577
mkdir /var/run/defectdojo && \
7678
chmod -R g=u /var/run/defectdojo && \
79+
chown -R ${uid}:${gid} /var/run/defectdojo && \
80+
chmod -R g=u /run/defectdojo && \
81+
chown -R ${uid}:${gid} /run/defectdojo && \
7782
mkdir -p /etc/nginx/ssl && \
7883
chmod -R g=u /etc/nginx && \
84+
chown -R ${uid}:${gid} /etc/nginx && \
7985
true
8086
ENV \
8187
DD_UWSGI_PASS="uwsgi_server" \
@@ -86,6 +92,6 @@ ENV \
8692
NGINX_METRICS_ENABLED="false" \
8793
METRICS_HTTP_AUTH_USER="" \
8894
METRICS_HTTP_AUTH_PASSWORD=""
89-
USER ${uid}
95+
USER ${uid}:${gid}
9096
EXPOSE 8080
9197
ENTRYPOINT ["/entrypoint-nginx.sh"]

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ services:
1919
NGINX_METRICS_ENABLED: "${NGINX_METRICS_ENABLED:-false}"
2020
DD_UWSGI_HOST: "${DD_UWSGI_HOST:-uwsgi}"
2121
DD_UWSGI_PORT: "${DD_UWSGI_PORT:-3031}"
22+
read_only: true
2223
volumes:
2324
- defectdojo_media:/usr/share/nginx/html/media
25+
tmpfs:
26+
- /run/defectdojo:uid=101,gid=101
27+
- /var/cache/nginx:uid=101,gid=101
28+
- /etc/nginx/ssl:uid=101,gid=101
2429
ports:
2530
- target: 8080
2631
published: ${DD_PORT:-8080}

0 commit comments

Comments
 (0)