From 4c4f308103525a73ff31defb8bb279f3b4cf8686 Mon Sep 17 00:00:00 2001 From: Haroon Sheikh Date: Sat, 16 Mar 2024 04:28:16 +0000 Subject: [PATCH] Adds a workflow for jdk21 (#59) --- .github/workflows/_build-template.yml | 19 ++++++++++++++----- .github/workflows/jdk-17.yml | 3 ++- .github/workflows/jdk-21.yml | 17 +++++++++++++++++ .github/workflows/openjdk-11.yml | 3 ++- Makefile | 21 +++++++++++++++++---- README.md | 10 ++++++++++ {jdk-17 => eclipse-temurin}/Dockerfile | 3 ++- 7 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/jdk-21.yml rename {jdk-17 => eclipse-temurin}/Dockerfile (95%) diff --git a/.github/workflows/_build-template.yml b/.github/workflows/_build-template.yml index aa6465c..60c9991 100644 --- a/.github/workflows/_build-template.yml +++ b/.github/workflows/_build-template.yml @@ -2,11 +2,19 @@ on: workflow_call: inputs: directory: + default: 'eclipse-temurin' + required: false + type: string + base_image_version: required: true type: string - default_image: + image_version: required: true type: string + default_image: + default: false + required: false + type: boolean jobs: build: @@ -38,12 +46,12 @@ jobs: flavor: | latest=false tags: | - type=raw,value=latest,enable=${{ inputs.directory == 'openjdk-11' }},priority=1000 - type=raw,value=${{ inputs.directory }} + type=raw,value=latest,enable=${{ inputs.default_image }},priority=1000 + type=raw,value=${{ inputs.image_version }} type=semver,pattern={{version}},enable=${{ inputs.default_image }},priority=900 type=semver,pattern={{major}}.{{minor}},enable=${{ inputs.default_image }},priority=800 - type=semver,pattern={{version}},suffix=-${{ inputs.directory }},priority=700 - type=ref,event=pr,prefix=pr-,suffix=-${{ inputs.directory }} + type=semver,pattern={{version}},suffix=-${{ inputs.image_version }},priority=700 + type=ref,event=pr,prefix=pr-,suffix=-${{ inputs.image_version }} - name: Login to Docker Hub if: github.event_name == 'release' && github.event.action == 'published' @@ -65,6 +73,7 @@ jobs: with: provenance: false build-args: | + BASE_IMAGE_TAG=${{ inputs.base_image_version }} GAUGE_VERSION=${{ env.GAUGE_LATEST_RELEASE }} GAUGE_REPORTPORTAL_VERSION=${{ env.REPORTPORTAL_LATEST_RELEASE }} context: . diff --git a/.github/workflows/jdk-17.yml b/.github/workflows/jdk-17.yml index 6872c6c..d8ed97a 100644 --- a/.github/workflows/jdk-17.yml +++ b/.github/workflows/jdk-17.yml @@ -12,6 +12,7 @@ jobs: build: uses: ./.github/workflows/_build-template.yml with: - directory: jdk-17 + base_image_version: 17-jdk + image_version: jdk-17 default_image: true secrets: inherit diff --git a/.github/workflows/jdk-21.yml b/.github/workflows/jdk-21.yml new file mode 100644 index 0000000..1e8a847 --- /dev/null +++ b/.github/workflows/jdk-21.yml @@ -0,0 +1,17 @@ +name: jdk-21 +on: + release: + types: [published] + push: + branches: + - 'master' + pull_request: + branches: + - 'master' +jobs: + build: + uses: ./.github/workflows/_build-template.yml + with: + base_image_version: 21-jdk + image_version: jdk-21 + secrets: inherit diff --git a/.github/workflows/openjdk-11.yml b/.github/workflows/openjdk-11.yml index 9ba2dbf..c9037fb 100644 --- a/.github/workflows/openjdk-11.yml +++ b/.github/workflows/openjdk-11.yml @@ -13,5 +13,6 @@ jobs: uses: ./.github/workflows/_build-template.yml with: directory: openjdk-11 - default_image: false + base_image_version: openjdk-11 + image_version: openjdk-11 secrets: inherit diff --git a/Makefile b/Makefile index bf0823a..0cc8fb7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -default: docker_buildx docker_build docker_build_jdk17 +default: docker_buildx docker_build docker_build_jdk17 docker_build_jdk21 PROJECT_USERNAME ?= sitture PROJECT_REPONAME ?= docker-gauge-java @@ -7,13 +7,14 @@ SHA1 ?= $$(git rev-parse --verify HEAD) TAG ?= $$(git describe --tags `git rev-list --tags --max-count=1`) JDK11_TAG = openjdk-11 JDK17_TAG = jdk-17 +JDK21_TAG = jdk-21 REPORTPORTAL_LATEST_RELEASE = $$(curl --silent "https://api.github.com/repos/reportportal/agent-net-gauge/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') docker_buildx: @docker buildx create --use docker_build: - @docker buildx build --progress=plain --pull \ + @docker buildx build --progress=plain \ --file ${JDK11_TAG}/Dockerfile \ --build-arg GAUGE_VERSION=$(TAG) \ --build-arg GAUGE_REPORTPORTAL_VERSION=$(REPORTPORTAL_LATEST_RELEASE) \ @@ -23,11 +24,23 @@ docker_build: -t $(DOCKER_IMAGE):latest . docker_build_jdk17: - @docker buildx build --progress=plain --pull \ - --file ${JDK17_TAG}/Dockerfile \ + @docker buildx build --progress=plain \ + --file eclipse-temurin/Dockerfile \ + --build-arg BASE_IMAGE_TAG=17-jdk \ --build-arg GAUGE_VERSION=$(TAG) \ --build-arg GAUGE_REPORTPORTAL_VERSION=$(REPORTPORTAL_LATEST_RELEASE) \ --platform linux/arm64,linux/amd64 \ -t $(DOCKER_IMAGE):$(TAG) \ -t $(DOCKER_IMAGE):$(JDK17_TAG) \ -t $(DOCKER_IMAGE):$(TAG)-$(JDK17_TAG) . + +docker_build_jdk21: + @docker buildx build --progress=plain \ + --file eclipse-temurin/Dockerfile \ + --build-arg BASE_IMAGE_TAG=21-jdk \ + --build-arg GAUGE_VERSION=$(TAG) \ + --build-arg GAUGE_REPORTPORTAL_VERSION=$(REPORTPORTAL_LATEST_RELEASE) \ + --platform linux/arm64,linux/amd64 \ + -t $(DOCKER_IMAGE):$(TAG) \ + -t $(DOCKER_IMAGE):$(JDK21_TAG) \ + -t $(DOCKER_IMAGE):$(TAG)-$(JDK21_TAG) . \ No newline at end of file diff --git a/README.md b/README.md index b811d14..02831f7 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,16 @@ Pull the latest Image with docker pull sitture/docker-gauge-java:latest ``` +Or you can build an image with remote Dockerfile: + +```bash +docker build --progress=plain --pull \ + --build-arg BASE_IMAGE_TAG=21-jdk \ + --build-arg GAUGE_VERSION=1.6.4 \ + -t sitture/docker-gauge-java:latest \ + "github.com/sitture/docker-gauge-java.git#:eclipse-temurin" +``` + ### Using `docker run` ```bash diff --git a/jdk-17/Dockerfile b/eclipse-temurin/Dockerfile similarity index 95% rename from jdk-17/Dockerfile rename to eclipse-temurin/Dockerfile index 0cf823a..97eb490 100644 --- a/jdk-17/Dockerfile +++ b/eclipse-temurin/Dockerfile @@ -1,4 +1,5 @@ -FROM eclipse-temurin:17-jdk +ARG BASE_IMAGE_TAG +FROM eclipse-temurin:${BASE_IMAGE_TAG} # Build-time metadata as defined at http://label-schema.org