forked from lucko/bytebin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
62 lines (49 loc) · 1.41 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# bytebin Dockerfile
# Copyright (c) lucko - licenced MIT
# --------------
# BUILD JRE STAGE
# --------------
FROM alpine as build-jre
RUN apk add --no-cache openjdk17
RUN apk add --no-cache binutils
# create a minimal JRE
RUN jlink \
--add-modules java.base,java.logging,java.xml,java.desktop,java.management,java.sql,java.naming,jdk.unsupported \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /jre
# --------------
# 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 --no-transfer-progress -B package
# --------------
# RUN STAGE
# --------------
FROM alpine
# copy JRE from build stage
ENV JAVA_HOME=/opt/java
ENV PATH "${JAVA_HOME}/bin:${PATH}"
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-project /bytebin/target/bytebin.jar .
# define a volume for the stored content
RUN mkdir content logs db
VOLUME ["/opt/bytebin/content", "/opt/bytebin/logs", "/opt/bytebin/db"]
# define a healthcheck
HEALTHCHECK --interval=1m --timeout=5s \
CMD wget http://localhost:8080/health -q -O - | grep -c '{"status":"ok"}' || exit 1
# run the app
CMD ["java", "-jar", "bytebin.jar"]
EXPOSE 8080/tcp