From 1fd90e68d07827b3c98f9351427a5723251d75a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Mon, 9 Nov 2026 17:11:55 +0100 Subject: [PATCH 1/2] Docker image on Java 21, slim and multi-arch, built from the sources; a workflow publishes it per release The image was the Maven build image (1.4 GB, amd64 only) running the jar from target/. It is now a multi-stage build: Maven on eclipse-temurin 21 builds, eclipse-temurin:21-jre runs (about 0.5 GB), for amd64 and arm64. The runnable jar is built with the shade plugin, which merges Jena's META-INF/services files; the assembly plugin keeps one of each, which leaves Jena's initialisation to the order the jars were unpacked in. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/docker.yml | 44 ++++++++++++++++++++++++++++++++++++ Dockerfile | 21 +++++++++++------ pom.xml | 40 ++++++++++++++++++++------------ 3 files changed, 83 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..5641572 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,44 @@ +name: Docker + +# The image of a release, for amd64 and arm64: pushed as the release's version and as latest when a release tag +# (json2rdf-) is pushed, or by hand for a tag given. Needs the repository secrets DOCKERHUB_USERNAME and +# DOCKERHUB_TOKEN. +on: + push: + tags: ['json2rdf-*'] + workflow_dispatch: + inputs: + tag: + description: 'the release tag to build (json2rdf-)' + required: true + +env: + IMAGE: atomgraph/json2rdf + +jobs: + image: + runs-on: ubuntu-latest + steps: + - name: The release's version + id: version + run: | + tag="${{ github.event.inputs.tag || github.ref_name }}" + echo "tag=$tag" >> "$GITHUB_OUTPUT" + echo "version=${tag#json2rdf-}" >> "$GITHUB_OUTPUT" + - uses: actions/checkout@v4 + with: + ref: ${{ steps.version.outputs.tag }} + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ env.IMAGE }}:${{ steps.version.outputs.version }} + ${{ env.IMAGE }}:latest diff --git a/Dockerfile b/Dockerfile index a9f6f7f..aebf1e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,20 @@ -FROM maven:3.8.4-openjdk-17 as maven +# Built from the sources at the tag being released; the image is the CLI, called as `docker run -i atomgraph/json2rdf +# ` with the JSON on standard input and the RDF on standard output. -LABEL maintainer="martynas@atomgraph.com" - -COPY . /usr/src/JSON2RDF +FROM maven:3.9.11-eclipse-temurin-21 AS build WORKDIR /usr/src/JSON2RDF -RUN mvn clean install +COPY pom.xml . +RUN mvn -B -q dependency:go-offline + +COPY src src +RUN mvn -B clean package + +FROM eclipse-temurin:21-jre + +LABEL maintainer="martynas@atomgraph.com" -### entrypoint +COPY --from=build /usr/src/JSON2RDF/target/json2rdf-*-jar-with-dependencies.jar /usr/local/lib/json2rdf.jar -ENTRYPOINT ["java", "-jar", "target/json2rdf-jar-with-dependencies.jar"] \ No newline at end of file +ENTRYPOINT ["java", "-jar", "/usr/local/lib/json2rdf.jar"] diff --git a/pom.xml b/pom.xml index 863b2ff..a90056f 100644 --- a/pom.xml +++ b/pom.xml @@ -84,31 +84,41 @@ 17 + org.apache.maven.plugins - maven-assembly-plugin + maven-shade-plugin + 3.6.1 - create-my-bundle - package + package - single + shade - - jar-with-dependencies - + true + jar-with-dependencies + false + + + + com.atomgraph.etl.json.JSON2RDF + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + - - - - true - com.atomgraph.etl.json.JSON2RDF - - - org.apache.maven.plugins From 5ed05ddb31d993bfed6e7a22c7fe854c9fcf42b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Mon, 9 Nov 2026 17:42:55 +0100 Subject: [PATCH 2/2] Release images tagged with the minor and major versions too; the Docker Hub user is a repository variable, as LinkedDataHub's Co-Authored-By: Claude Opus 5.5 --- .github/workflows/docker.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5641572..c31ae27 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,8 +1,8 @@ name: Docker -# The image of a release, for amd64 and arm64: pushed as the release's version and as latest when a release tag -# (json2rdf-) is pushed, or by hand for a tag given. Needs the repository secrets DOCKERHUB_USERNAME and -# DOCKERHUB_TOKEN. +# The image of a release, for amd64 and arm64 (arm64 emulated: the build is small): pushed as the release's version, +# its minor and major versions and latest when a release tag (json2rdf-) is pushed, or by hand for a tag given. +# Needs the repository variable DOCKERHUB_USERNAME and the secret DOCKERHUB_TOKEN, as LinkedDataHub's release. on: push: tags: ['json2rdf-*'] @@ -23,8 +23,13 @@ jobs: id: version run: | tag="${{ github.event.inputs.tag || github.ref_name }}" + version="${tag#json2rdf-}" + major="${version%%.*}" + minor="${version%.*}" echo "tag=$tag" >> "$GITHUB_OUTPUT" - echo "version=${tag#json2rdf-}" >> "$GITHUB_OUTPUT" + echo "version=$version" >> "$GITHUB_OUTPUT" + echo "minor=$minor" >> "$GITHUB_OUTPUT" + echo "major=$major" >> "$GITHUB_OUTPUT" - uses: actions/checkout@v4 with: ref: ${{ steps.version.outputs.tag }} @@ -32,7 +37,7 @@ jobs: - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - uses: docker/build-push-action@v6 with: @@ -41,4 +46,6 @@ jobs: push: true tags: | ${{ env.IMAGE }}:${{ steps.version.outputs.version }} + ${{ env.IMAGE }}:${{ steps.version.outputs.minor }} + ${{ env.IMAGE }}:${{ steps.version.outputs.major }} ${{ env.IMAGE }}:latest