Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93f668b

Browse files
committed
feat(non-root): updates dockerfile to add non-root user: projects
1 parent 1a5cf06 commit 93f668b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Dockerfile

Lines changed: 9 additions & 4 deletions
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

@@ -15,3 +19,4 @@ RUN ["mvn", "de.qaware.maven:go-offline-maven-plugin:resolve-dependencies", "-P"
1519
COPY . .
1620

1721
ENTRYPOINT ["sh"]
22+

0 commit comments

Comments
 (0)