-
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
Showing
4 changed files
with
169 additions
and
35 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,53 @@ | ||
name: Docker | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
on: | ||
|
||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
# This is used to complete the identity challenge | ||
# with sigstore/fulcio when running outside of PRs. | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
id: push | ||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||
with: | ||
context: . | ||
file: ./leyden/Dockerfile | ||
push: true | ||
tags: ghcr.io/${{ github.repository }}:hello-world-leyden | ||
|
||
|
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
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,22 @@ | ||
FROM debian:latest | ||
|
||
ENV JDK_URL=https://download.java.net/java/early_access/leyden/2/openjdk-24-leyden+2-8_linux-x64_bin.tar.gz | ||
ENV JAVA_HOME=/opt/java/openjdk | ||
ENV PATH="$JAVA_HOME/bin:$PATH" | ||
|
||
RUN apt-get update && apt-get install -y wget tar && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir -p "$JAVA_HOME" && wget -qO- "$JDK_URL" | tar -xz --strip-components=1 -C "$JAVA_HOME" | ||
|
||
RUN mkdir tmp | ||
COPY ./build.gradle ./gradlew ./settings.gradle tmp/ | ||
COPY ./gradle tmp/gradle | ||
COPY ./src tmp/src | ||
RUN ./tmp/gradlew assemble | ||
|
||
COPY ./leyden/unpack-executable-jar.sh tmp/ | ||
RUN ./tmp/unpack-executable-jar.sh -d build-unpacked tmp/build/libs/hello-world-0.0.1-SNAPSHOT.jar | ||
RUN rm -rf tmp | ||
RUN java -Dspring.aot.enabled=true -Dspring.context.exit=onRefresh -XX:CacheDataStore=build-unpacked/application.cds -jar build-unpacked/run-app.jar | ||
|
||
CMD ["java", "-Dspring.aot.enabled=true", "-XX:CacheDataStore=build-unpacked/application.cds", "-jar", "build-unpacked/run-app.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# https://github.com/sdeleuze/spring-petclinic-data-jdbc/blob/cds/unpack-executable-jar.sh | ||
|
||
while test $# -gt 0; do | ||
case "$1" in | ||
-h|--help) | ||
echo "unpack-executable-jar.sh - unpack Spring Boot executable JAR in order to run" | ||
echo "the application efficiently and maximizing CDS effectiveness." | ||
echo " " | ||
echo "my-dir | ||
├── application | ||
│ └── my-app-1.0.0-SNAPSHOT.jar | ||
├── dependencies | ||
│ ├── ... | ||
│ ├── spring-context-6.1.0.jar | ||
│ ├── spring-context-support-6.1.0.jar | ||
│ ├── ... | ||
└── run-app.jar" | ||
echo " " | ||
echo "unpack-executable-jar.sh [options] application.jar" | ||
echo " " | ||
echo "options:" | ||
echo "-d directory Create the files in directory" | ||
echo "-h, --help Show brief help" | ||
exit 0 | ||
;; | ||
-d) | ||
shift | ||
if test $# -gt 0; then | ||
export DESTINATION=$1 | ||
else | ||
echo "no destination specified" | ||
exit 1 | ||
fi | ||
shift | ||
;; | ||
*) | ||
export JAREXE=$1 | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
if [ -z "$JAREXE" ]; then | ||
echo "specifying the executable JAR is mandatory" | ||
exit 1 | ||
fi | ||
|
||
UNPACK_TMPDIR="${TMPDIR}unpack-executable-jar" | ||
if [ -d "$UNPACK_TMPDIR" ]; then rm -Rf "$UNPACK_TMPDIR"; fi | ||
|
||
if [ -z "$DESTINATION" ]; then | ||
DESTINATION="$(pwd)" | ||
fi | ||
|
||
unzip -q "$JAREXE" -d "$UNPACK_TMPDIR" | ||
mkdir -p "${DESTINATION}/application" | ||
mkdir -p "${DESTINATION}/dependencies" | ||
|
||
jar cf "${DESTINATION}/application/$(basename "$JAREXE")" -C "${UNPACK_TMPDIR}/BOOT-INF/classes/" . | ||
|
||
MANIFEST_RUN_APP="${UNPACK_TMPDIR}/MANIFEST-RUN-APP.MF" | ||
MAIN_CLASS=$(grep "Start-Class:" "${UNPACK_TMPDIR}/META-INF/MANIFEST.MF" | cut -d ' ' -f 2) | ||
|
||
echo "Manifest-Version: 1.0" > "${MANIFEST_RUN_APP}" | ||
echo "Main-Class: ${MAIN_CLASS}" >> "${MANIFEST_RUN_APP}" | ||
echo "Class-Path: application/$(basename "$JAREXE")" >> "${MANIFEST_RUN_APP}" | ||
cut -d '/' -f 3 < "${UNPACK_TMPDIR}/BOOT-INF/classpath.idx" | cut -d '"' -f 1 | while IFS= read -r lib | ||
do | ||
cp -r "${UNPACK_TMPDIR}/BOOT-INF/lib/${lib}" "${DESTINATION}/dependencies/" | ||
echo " dependencies/$lib" >> "${MANIFEST_RUN_APP}" | ||
done | ||
|
||
jar cfm "${DESTINATION}/run-app.jar" "${MANIFEST_RUN_APP}" |