Skip to content

Commit

Permalink
Update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
lucko committed Feb 5, 2023
1 parent 95bb30d commit 4d77104
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# Copyright (c) lucko - licenced MIT

# --------------
# BUILD STAGE
# BUILD JRE STAGE
# --------------
FROM alpine as build

# install jdk17 and binutils (for objcopy, needed by jlink)
RUN apk add --no-cache openjdk17 binutils
FROM alpine as build-jre
RUN apk add --no-cache openjdk17
RUN apk add --no-cache binutils

# create a minimal JRE
RUN jlink \
Expand All @@ -18,14 +17,19 @@ RUN jlink \
--compress=2 \
--output /jre

# install maven
RUN apk add maven

# --------------
# BUILD PROJECT STAGE
# --------------
FROM alpine as build-project
RUN apk add --no-cache openjdk17
RUN apk add --no-cache maven

# compile the project
WORKDIR /bytebin
COPY pom.xml ./
COPY src/ ./src/
RUN mvn -B package
RUN mvn --no-transfer-progress -B package


# --------------
Expand All @@ -36,14 +40,14 @@ FROM alpine
# copy JRE from build stage
ENV JAVA_HOME=/opt/java
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=build /jre $JAVA_HOME
COPY --from=build-jre /jre $JAVA_HOME

RUN addgroup -S bytebin && adduser -S -G bytebin bytebin
USER bytebin

# copy app from build stage
WORKDIR /opt/bytebin
COPY --from=build /bytebin/target/bytebin.jar .
COPY --from=build-project /bytebin/target/bytebin.jar .

# define a volume for the stored content
RUN mkdir content logs db
Expand Down

0 comments on commit 4d77104

Please sign in to comment.