-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
995bfed
commit 209c417
Showing
2 changed files
with
47 additions
and
13 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 |
---|---|---|
@@ -1,19 +1,36 @@ | ||
# After spending lots of time in Docker hell I don't have any more apetite for | ||
# this. I'm lost in a sea of different JRE/JDK distributions with strange names, | ||
# and they all give me different linker errors (at runtime!) it's completely | ||
# impossible to debug. God, I hate the JVM. | ||
# If someone who actually knows what they're doing comes around, it'd be great | ||
# to separate this out to a builder/runner staged build. This leads to a | ||
# horrendously large image. | ||
# Example of custom Java runtime using jlink in a multi-stage container build | ||
FROM eclipse-temurin:11 as jre-build | ||
|
||
# Create a custom Java runtime | ||
RUN $JAVA_HOME/bin/jlink \ | ||
--add-modules java.base \ | ||
--add-modules java.logging \ | ||
--strip-debug \ | ||
--no-man-pages \ | ||
--no-header-files \ | ||
--compress=2 \ | ||
--output /javaruntime | ||
|
||
# Stage 1: Build stage | ||
FROM gradle:7-jdk11 AS build | ||
|
||
WORKDIR /workdir | ||
|
||
COPY . . | ||
RUN gradle build | ||
RUN gradle fatJar | ||
|
||
# Stage 2: Runtime stage | ||
# Needs to be a recent ish debian image to have a new enough | ||
# libc. Still haven't understood the finer points here. | ||
FROM debian:bookworm-slim | ||
|
||
ENV JAVA_HOME=/opt/java/openjdk | ||
ENV PATH "${JAVA_HOME}/bin:${PATH}" | ||
COPY --from=jre-build /javaruntime $JAVA_HOME | ||
|
||
WORKDIR /app | ||
|
||
# TODO: parameterize the version? | ||
RUN unzip build/distributions/deskriptor-1.0-SNAPSHOT.zip && \ | ||
cp -r /workdir/deskriptor-1.0-SNAPSHOT /deskriptor | ||
COPY --from=build /workdir/build/libs/deskriptor-1.0-SNAPSHOT-standalone.jar /app/ | ||
COPY logging.properties /logging.properties | ||
|
||
ENTRYPOINT [ "/deskriptor/bin/deskriptor"] | ||
ENTRYPOINT [ "java", "-jar", "/app/deskriptor-1.0-SNAPSHOT-standalone.jar" ] |
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