Skip to content

Commit

Permalink
Merge pull request #1261 from CDCgov/issue-1211-docker_lower_privs
Browse files Browse the repository at this point in the history
Low Privilege User for Running the Application
  • Loading branch information
halprin authored Aug 22, 2024
2 parents 219bfbd + f15ac4d commit 111c000
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Use Linux-Alpine image
FROM amazoncorretto:17.0.12-alpine

RUN apk -U upgrade
RUN apk update && apk -U upgrade && rm -rf /var/cache/apk/*

RUN adduser -S myLowPrivilegeUser
USER myLowPrivilegeUser

ARG JAR_LIB_FILE=./app/build/libs/app-all.jar

# Create directory and switch to it
WORKDIR /app
WORKDIR /home/myLowPrivilegeUser/app/

# Add application JAR to created folder
COPY ${JAR_LIB_FILE} app.jar
COPY --chown=myLowPrivilegeUser ${JAR_LIB_FILE} app.jar

# Run the api
CMD ["java", "-jar", "app.jar"]
Expand Down

0 comments on commit 111c000

Please sign in to comment.