Skip to content

Commit 03a2786

Browse files
committed
Use nginx-unprivileged base image
The new images exposes 8080 port, runs as nginx (non-root user). There is no need to copy-paste either CMD or ENTRYPOINT. nginx-unprivileged configuration includes conf.d directory, thus no need to copy-paste the boilerplate configuration. The custom entrypoint can be moved into existing /docker-entrypoint.d/ directory. Use the same `--chown` strategy as already used in Dockerfile made for DependencyTrack/dependency-track. Signed-off-by: Alex Szakaly <[email protected]>
1 parent 317d354 commit 03a2786

File tree

5 files changed

+28
-47
lines changed

5 files changed

+28
-47
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ docs/
1111
node_modules/
1212
release.sh
1313
snapshot.sh
14-
!docker/etc/nginx/nginx.conf
14+
!docker/etc/nginx/conf.d/default.conf
1515
!docker/docker-entrypoint.sh

docker/Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,25 @@ RUN npm run build
1919
###############################
2020
# Production image #
2121
###############################
22-
FROM nginx:stable-alpine
22+
FROM nginxinc/nginx-unprivileged:stable-alpine
2323

2424
# jq is required for entrypoint script
25+
USER root
2526
RUN apk --no-cache add jq
2627

27-
COPY ./docker/etc/nginx/nginx.conf /etc/nginx/nginx.conf
28+
COPY ./docker/etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
2829

29-
COPY --from=build /app/dist /app
30+
COPY --chown=101:101 --from=build /app/dist /app
31+
32+
# Specify the user to run as (in numeric format for compatibility with Kubernetes/OpenShift's SCC)
33+
# Inherited from parent image
34+
# See https://github.com/nginxinc/docker-nginx-unprivileged/blob/main/stable/alpine/Dockerfile#L139
35+
USER 101
3036

3137
# Set default settings that may get overridden to empty values by
3238
# the entrypoint script, if not explicitly provided by the user
3339
ENV OIDC_SCOPE "openid profile email"
3440

3541
# Setup entrypoint
3642
WORKDIR /app
37-
COPY ./docker/docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
38-
ENTRYPOINT [ "/usr/bin/docker-entrypoint.sh" ]
39-
40-
# Inherited from parent image
41-
# See https://github.com/nginxinc/docker-nginx/blob/1.18.0/stable/alpine/Dockerfile#L115
42-
CMD ["nginx", "-g", "daemon off;"]
43+
COPY ./docker/docker-entrypoint.sh /docker-entrypoint.d/30-oidc-configuration.sh

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ services:
2828
# volumes:
2929
# - "/host/path/to/config.json:/app/static/config.json"
3030
ports:
31-
- "8080:80"
31+
- "8080:8080"
3232
restart: unless-stopped
3333

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
server {
2+
listen 8080;
3+
server_name _;
4+
5+
location / {
6+
root /app;
7+
index index.html;
8+
try_files $uri $uri/ /index.html;
9+
}
10+
11+
error_page 500 502 503 504 /50x.html;
12+
13+
location = /50x.html {
14+
root /usr/share/nginx/html;
15+
}
16+
}

docker/etc/nginx/nginx.conf

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)