Skip to content

Commit

Permalink
Publish JVM Based Docker Images
Browse files Browse the repository at this point in the history
As a quick-fix for native ARM64 Support for Apple Silicon, JVM
based Images are now published for both x86 and ARM.
  • Loading branch information
dnl50 committed Apr 2, 2024
1 parent ec46c45 commit 4d8a6d5
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 21 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v3

- name: Run Gradle 'build' Task
run: ./gradlew build

#- name: Copy OpenAPI Specification
# run: ./gradlew copyOpenApiSpec

#- name: Build Svelte App
# uses: docker/build-push-action@v4
#with:
#context: web
35 changes: 27 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
name: Publish Docker image
name: Publish Artifacts

on:
release:
types: [ released, prereleased ]

jobs:
push_to_registry:
name: Push Docker images to Docker Hub
publish_artifacts:
name: Publish Artifacts
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Backend Image
run: ./gradlew build -Dquarkus.native.compression.level=9 -Dquarkus.container-image.push=true
- name: Build and Push Native Image
env:
QUARKUS_CONTAINER_IMAGE_BUILD: true
QUARKUS_CONTAINER_IMAGE_PUSH: true
QUARKUS_PACKAGE_TYPE: native
QUARKUS_NATIVE_COMPRESSION_LEVEL: 9
run: ./gradlew clean build

- name: Copy Linux Binary to Temporary Folder
run: cp app/build/tsa-*-runner $RUNNER_TEMP/tsa-linux-amd64
Expand All @@ -43,6 +54,14 @@ jobs:
asset_name: tsa-linux-amd64
asset_content_type: application/octet-stream

- name: Build and Push JVM Images
env:
QUARKUS_CONTAINER_IMAGE_BUILD: true
QUARKUS_CONTAINER_IMAGE_PUSH: true
QUARKUS_PACKAGE_TYPE: jar
QUARKUS_DOCKER_BUILDX_PLATFORM: linux/amd64,linux/arm64
run: ./gradlew clean build -PimageTagSuffix=jvm

- name: Update Docker Hub description
if: ${{ github.event.action == 'released' }}
uses: peter-evans/dockerhub-description@v3
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ volume to the `/work/data` will make the DB data persistent.
The keystore containing the certificate and private key used to sign the requests with is loaded
from `/work/keystore.p12` by default.

There are two Docker Image variants: _Native_ and _JVM_.
Native Images (e.g. `dnl50/tsa-server:3.1.0`) are only available for `x86-64`. The JVM variant
(e.g. `dnl50/tsa-server:3.1.0-jvm`) is available for `x86-64` and `arm64`.

## Features

### Time Stamping
Expand Down
9 changes: 7 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,14 @@ spotless {

quarkus {
set("native.container-build", "true")
set("container-image.build", "true")
set("container-image.group", "dnl50")
set("container-image.name", "tsa-server")
set("package.type", "native")
set("container-image.tag", objects.property<String>().value(provider {
if (project.hasProperty("imageTagSuffix")) {
"${project.version}-${project.property("imageTagSuffix")}"
} else {
project.version.toString()
}
}))
finalName.set("tsa-${project.version}")
}
23 changes: 23 additions & 0 deletions app/src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Based on Quarkus' Dockerfile.jvm template for Gradle
FROM registry.access.redhat.com/ubi8/openjdk-21-runtime:1.19

ENV LANGUAGE='en_US:en'

# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=185 build/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 build/quarkus-app/*.jar /deployments/
COPY --chown=185 build/quarkus-app/app/ /deployments/app/
COPY --chown=185 build/quarkus-app/quarkus/ /deployments/quarkus/

USER root
RUN mkdir -p /work/data \
&& chown -R 185:root /work

EXPOSE 8080
USER 185
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"

VOLUME ["/work/data"]

ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]

0 comments on commit 4d8a6d5

Please sign in to comment.