Skip to content

Commit

Permalink
Test Publishing of JVM Images
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Meier authored and dnl50 committed Apr 2, 2024
1 parent 45c23e9 commit 1161820
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
*.bat text eol=crlf
* text eol=lf

*.html text diff=html
*.java text diff=java
*.css text diff=css

*.jar binary
*.png binary
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 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 assemble -PimageTagSuffix=jvm

- name: Update Docker Hub description
if: ${{ github.event.action == 'released' }}
uses: peter-evans/dockerhub-description@v3
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" ]
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.

0 comments on commit 1161820

Please sign in to comment.