Skip to content

Commit

Permalink
Adds a workflow for jdk21 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
haroon-sheikh authored Mar 16, 2024
1 parent 2281bfe commit 4c4f308
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 12 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/_build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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'
Expand All @@ -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: .
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/jdk-17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions .github/workflows/jdk-21.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion .github/workflows/openjdk-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) \
Expand All @@ -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) .
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion jdk-17/Dockerfile → eclipse-temurin/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 4c4f308

Please sign in to comment.