Skip to content

Commit 4d77104

Browse files
committed
Update dockerfile
1 parent 95bb30d commit 4d77104

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Dockerfile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
# Copyright (c) lucko - licenced MIT
33

44
# --------------
5-
# BUILD STAGE
5+
# BUILD JRE STAGE
66
# --------------
7-
FROM alpine as build
8-
9-
# install jdk17 and binutils (for objcopy, needed by jlink)
10-
RUN apk add --no-cache openjdk17 binutils
7+
FROM alpine as build-jre
8+
RUN apk add --no-cache openjdk17
9+
RUN apk add --no-cache binutils
1110

1211
# create a minimal JRE
1312
RUN jlink \
@@ -18,14 +17,19 @@ RUN jlink \
1817
--compress=2 \
1918
--output /jre
2019

21-
# install maven
22-
RUN apk add maven
20+
21+
# --------------
22+
# BUILD PROJECT STAGE
23+
# --------------
24+
FROM alpine as build-project
25+
RUN apk add --no-cache openjdk17
26+
RUN apk add --no-cache maven
2327

2428
# compile the project
2529
WORKDIR /bytebin
2630
COPY pom.xml ./
2731
COPY src/ ./src/
28-
RUN mvn -B package
32+
RUN mvn --no-transfer-progress -B package
2933

3034

3135
# --------------
@@ -36,14 +40,14 @@ FROM alpine
3640
# copy JRE from build stage
3741
ENV JAVA_HOME=/opt/java
3842
ENV PATH "${JAVA_HOME}/bin:${PATH}"
39-
COPY --from=build /jre $JAVA_HOME
43+
COPY --from=build-jre /jre $JAVA_HOME
4044

4145
RUN addgroup -S bytebin && adduser -S -G bytebin bytebin
4246
USER bytebin
4347

4448
# copy app from build stage
4549
WORKDIR /opt/bytebin
46-
COPY --from=build /bytebin/target/bytebin.jar .
50+
COPY --from=build-project /bytebin/target/bytebin.jar .
4751

4852
# define a volume for the stored content
4953
RUN mkdir content logs db

0 commit comments

Comments
 (0)