Skip to content

Commit

Permalink
update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
William Welling committed Aug 11, 2022
1 parent 6470571 commit bf6a15a
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
# Settings.
ARG USER_ID=3001
ARG USER_NAME=projectmanagement
ARG HOME_DIR=/$USER_NAME
ARG SOURCE_DIR=$HOME_DIR/source
ARG SOURCE_DIR=/$USER_NAME/source

# Maven stage.
FROM maven:3-openjdk-11-slim as maven
ARG USER_ID
ARG USER_NAME
ARG HOME_DIR
ARG SOURCE_DIR

# Create the group (use a high ID to attempt to avoid conflits).
RUN groupadd -g $USER_ID $USER_NAME

# Create the user (use a high ID to attempt to avoid conflits).
RUN useradd -d $HOME_DIR -m -u $USER_ID -g $USER_ID $USER_NAME
# Create the user and group (use a high ID to attempt to avoid conflicts).
RUN groupadd --non-unique -g $USER_ID $USER_NAME && \
useradd --non-unique -d /$USER_NAME -m -u $USER_ID -g $USER_ID $USER_NAME

# Update the system.
RUN apt-get update && apt-get upgrade -y
Expand All @@ -40,20 +36,17 @@ RUN mvn package -Pjar -DskipTests=true
FROM openjdk:11-jre-slim
ARG USER_ID
ARG USER_NAME
ARG HOME_DIR
ARG SOURCE_DIR

# Create the group (use a high ID to attempt to avoid conflits).
RUN groupadd -g $USER_ID $USER_NAME

# Create the user (use a high ID to attempt to avoid conflits).
RUN useradd -d $HOME_DIR -m -u $USER_ID -g $USER_ID $USER_NAME
# Create the user and group (use a high ID to attempt to avoid conflicts).
RUN groupadd --non-unique -g $USER_ID $USER_NAME && \
useradd --non-unique -d /$USER_NAME -m -u $USER_ID -g $USER_ID $USER_NAME

# Login as user.
USER $USER_NAME

# Set deployment directory.
WORKDIR $HOME_DIR
WORKDIR /$USER_NAME

# Copy over the built artifact from the maven image.
COPY --from=maven $SOURCE_DIR/target/ROOT.jar ./projectmanagement.jar
Expand Down

0 comments on commit bf6a15a

Please sign in to comment.