-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# bytebin Dockerfile | ||
# Copyright (c) lucko - licenced MIT | ||
|
||
# -------------- | ||
# BUILD STAGE | ||
# -------------- | ||
FROM eclipse-temurin:17-alpine as build | ||
|
||
# for objcopy, needed by jlink | ||
RUN apk add binutils | ||
|
||
# create a minimal JRE | ||
RUN $JAVA_HOME/bin/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 | ||
|
||
# install maven | ||
RUN apk add maven | ||
|
||
# compile the project | ||
COPY . /bytebin/ | ||
WORKDIR /bytebin | ||
RUN mvn clean 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 $JAVA_HOME | ||
|
||
# copy app from build stage | ||
COPY --from=build /bytebin/target/bytebin.jar /opt/bytebin/ | ||
|
||
# define a simple healthcheck | ||
HEALTHCHECK --interval=1m --timeout=3s \ | ||
CMD wget http://localhost:8080/ -q -O - > /dev/null 2>&1 || exit 1 | ||
|
||
# run the app | ||
WORKDIR /opt/bytebin | ||
CMD ["java", "-jar", "bytebin.jar"] | ||
EXPOSE 8080/tcp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters