Last active
May 1, 2025 09:02
-
-
Save MShekow/d7a3c0a8a9563af57965f5c36d7a6b1a to your computer and use it in GitHub Desktop.
Ubuntu Chiseled JRE image (based on OpenJDK) with Springboot Petclinic sample app
This file contains hidden or 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
| ARG UBUNTU_RELEASE=24.04 | |
| ARG CHISEL_VERSION=v1.1.0 | |
| FROM eclipse-temurin:21-jdk-noble AS build | |
| ADD https://github.com/spring-projects/spring-petclinic.git /app | |
| WORKDIR /app | |
| RUN ./mvnw package | |
| FROM ubuntu:$UBUNTU_RELEASE AS builder | |
| ARG TARGETARCH UBUNTU_RELEASE CHISEL_VERSION | |
| SHELL ["/bin/bash", "-oeux", "pipefail", "-c"] | |
| RUN apt-get update \ | |
| && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates | |
| ADD "https://github.com/canonical/chisel/releases/download/${CHISEL_VERSION}/chisel_${CHISEL_VERSION}_linux_${TARGETARCH}.tar.gz" \ | |
| chisel.tar.gz | |
| RUN tar -xvf chisel.tar.gz -C /usr/bin/ | |
| RUN apt-get install -y git file # file is needed by the chisel-wrapper script | |
| RUN git clone --depth 1 -b main https://github.com/canonical/rocks-toolbox /rocks-toolbox && mv /rocks-toolbox/chisel-wrapper /usr/local/bin/ && rm -rf /rocks-toolbox | |
| RUN mkdir -p /staging-rootfs/var/lib/dpkg | |
| RUN chisel-wrapper --generate-dpkg-status /staging-rootfs/var/lib/dpkg/status -- --release "ubuntu-$UBUNTU_RELEASE" --root /staging-rootfs \ | |
| base-files_base \ | |
| base-files_release-info \ | |
| base-files_chisel \ | |
| openjdk-21-jre-headless_standard | |
| RUN cp /etc/passwd /etc/group /staging-rootfs/etc \ | |
| && install -o ubuntu -g ubuntu -d /staging-rootfs/home/ubuntu | |
| FROM scratch | |
| COPY --from=builder /staging-rootfs / | |
| USER ubuntu | |
| WORKDIR /home/ubuntu | |
| # Note: the * wildcard resolves the concrete filename which changes over time, e.g. "spring-petclinic-3.4.0-SNAPSHOT.jar" | |
| COPY --from=build /app/target/spring-petclinic-*.jar /app/app.jar | |
| ARG TARGETARCH | |
| ENV PATH="$PATH:/usr/lib/jvm/java-21-openjdk-${TARGETARCH}/bin" | |
| ENTRYPOINT ["java", "-jar", "/app/app.jar"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment