Skip to content

Commit 55f8d9a

Browse files
committed
fix: removed nonroot user because we are using unprivileged nginx
TRACEFOSS-xxx
1 parent fa95c5b commit 55f8d9a

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

Dockerfile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Nonroot user is not needed beause we are using the "nginx-unprivileged" image
12
# STAGE 1: Build
23
FROM node:18-alpine as builder
34

@@ -20,8 +21,6 @@ HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=10s \
2021
CMD curl -fSs 127.0.0.1:8080/healthz || exit 1
2122

2223
USER root
23-
#Add a user with userid 8877 and name nonroot
24-
RUN addgroup -S nonrootgroup && adduser -u 8877 -D -S nonroot -G nonrootgroup
2524

2625
RUN rm /usr/share/nginx/html/index.html && rm /etc/nginx/conf.d/default.conf
2726

@@ -30,7 +29,7 @@ COPY --from=builder /ng-app/dist /usr/share/nginx/html
3029

3130
# Give ownership to nginx user over dir with content
3231

33-
RUN chown -R nonroot:nonrootgroup /usr/share/nginx/html/
32+
RUN chown -R nginx:nginx /usr/share/nginx/html/
3433
USER nginx
3534

3635
# Install Node.js from builder stage
@@ -46,8 +45,4 @@ COPY ./scripts/inject-dynamic-env.js /docker-entrypoint.d/
4645

4746
# Validate NGINX configuration
4847
RUN nginx -t
49-
50-
USER root
51-
52-
#Run Container as nonroot
53-
USER nonroot
48+
USER 101

charts/traceability-foss-frontend/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ podSecurityContext: { }
5555
securityContext:
5656
allowPrivilegeEscalation: false
5757
runAsNonRoot: true
58-
runAsUser: 8877
58+
runAsUser: 101
5959
# runAsGroup: 3000
6060

6161
service:

0 commit comments

Comments
 (0)