Skip to content

Commit 6f04f11

Browse files
committed
feat(non-root): updates dockerfile to add non-root user: projects
1 parent fb56ff8 commit 6f04f11

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Dockerfile

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
FROM maven:3.6-jdk-8-slim
22

3-
ENV APP_DIR /src/app/
3+
WORKDIR /src/app/
44

5-
RUN mkdir -p $APP_DIR
5+
COPY ./pom.xml .
66

7-
COPY ./pom.xml ${APP_DIR}
7+
RUN ["mkdir", "/home/projects"]
88

9-
WORKDIR ${APP_DIR}
9+
RUN groupadd projects && useradd -g projects projects && \
10+
chown -R projects:projects /src/app && \
11+
chown -R projects:projects /home/projects
12+
13+
USER projects
1014

1115
RUN ["mvn", "clean"]
1216

0 commit comments

Comments
 (0)