Skip to content
Snippets Groups Projects
Commit 553eaab3 authored by Yauheni  Rykhter (EPAM)'s avatar Yauheni Rykhter (EPAM)
Browse files

GONRG-7392: use non-root user for images

parent 073b9253
No related branches found
No related tags found
1 merge request!404GONRG-7392: use non-root user for images
Pipeline #195501 failed
...@@ -38,7 +38,7 @@ spec: ...@@ -38,7 +38,7 @@ spec:
{{- end }} {{- end }}
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
runAsUser: 0 runAsNonRoot: true
ports: ports:
- containerPort: 8080 - containerPort: 8080
resources: resources:
......
...@@ -6,5 +6,10 @@ ARG PORT ...@@ -6,5 +6,10 @@ ARG PORT
ENV PORT $PORT ENV PORT $PORT
# Copy the jar to the production image from the builder stage. # Copy the jar to the production image from the builder stage.
COPY provider/notification-${PROVIDER_NAME}/target/notification-${PROVIDER_NAME}-*-spring-boot.jar notification-${PROVIDER_NAME}.jar COPY provider/notification-${PROVIDER_NAME}/target/notification-${PROVIDER_NAME}-*-spring-boot.jar notification-${PROVIDER_NAME}.jar
# Add a non-root user
RUN groupadd -g 10001 -r nonroot \
&& useradd -g 10001 -r -u 10001 nonroot
# Run as non-root user
USER 10001:10001
# Run the web service on container startup. # Run the web service on container startup.
CMD java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${PORT} -Dlog4j.formatMsgNoLookups=true -jar /app/notification-${PROVIDER_NAME}.jar CMD java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${PORT} -Dlog4j.formatMsgNoLookups=true -jar /app/notification-${PROVIDER_NAME}.jar
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment