forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.nginx-alpine
84 lines (73 loc) · 2.21 KB
/
Dockerfile.nginx-alpine
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
# code: language=Dockerfile
# The code for the build image should be identical with the code in
# Dockerfile.django-alpine to use the caching mechanism of Docker.
# Ref: https://devguide.python.org/#branchstatus
FROM node:23.8.0-alpine3.20@sha256:1b4d82a2bee3b5ea9a9048bd3b326220ac77065a84cbef339a8f41c698f0ec66 AS node
FROM python:3.11.9-alpine3.20@sha256:f9ce6fe33d9a5499e35c976df16d24ae80f6ef0a28be5433140236c2ca482686 AS base
FROM base AS build
WORKDIR /app
RUN \
apk update && \
apk add --no-cache \
gcc \
build-base \
bind-tools \
postgresql16-client \
xmlsec \
git \
util-linux \
curl-dev \
openssl \
libffi-dev \
python3-dev \
libpq-dev \
&& \
rm -rf /var/cache/apk/* && \
true
COPY requirements.txt ./
# CPUCOUNT=1 is needed, otherwise the wheel for uwsgi won't always be build succesfully
# https://github.com/unbit/uwsgi/issues/1318#issuecomment-542238096
RUN CPUCOUNT=1 pip3 wheel --wheel-dir=/tmp/wheels -r ./requirements.txt
FROM build AS collectstatic
RUN apk add nodejs npm
RUN npm install -g yarn --force
# installing DefectDojo packages
RUN pip3 install \
--no-cache-dir \
--no-index \
--find-links=/tmp/wheels \
-r ./requirements.txt
# generate static files
COPY components/ ./components/
RUN \
cd components && \
yarn
COPY manage.py ./
COPY dojo/ ./dojo/
RUN env DD_SECRET_KEY='.' python3 manage.py collectstatic --noinput && true
FROM nginx:1.27.4-alpine@sha256:4ff102c5d78d254a6f0da062b3cf39eaf07f01eec0927fd21e219d0af8bc0591
ARG uid=1001
ARG appuser=defectdojo
COPY --from=collectstatic /app/static/ /usr/share/nginx/html/static/
COPY wsgi_params nginx/nginx.conf nginx/nginx_TLS.conf /etc/nginx/
COPY docker/entrypoint-nginx.sh /
RUN \
apk add --no-cache openssl && \
chmod -R g=u /var/cache/nginx && \
mkdir /var/run/defectdojo && \
chmod -R g=u /var/run/defectdojo && \
mkdir -p /etc/nginx/ssl && \
chmod -R g=u /etc/nginx && \
true
ENV \
DD_UWSGI_PASS="uwsgi_server" \
DD_UWSGI_HOST="uwsgi" \
DD_UWSGI_PORT="3031" \
GENERATE_TLS_CERTIFICATE="false" \
USE_TLS="false" \
NGINX_METRICS_ENABLED="false" \
METRICS_HTTP_AUTH_USER="" \
METRICS_HTTP_AUTH_PASSWORD=""
USER ${uid}
EXPOSE 8080
ENTRYPOINT ["/entrypoint-nginx.sh"]