Skip to content

Update Docker image GHA with new base images/runners #2

Update Docker image GHA with new base images/runners

Update Docker image GHA with new base images/runners #2

name: Build Docker images
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types: [published]
env:
BUILDX_CACHE: /tmp/.buildx-cache
CACHE_KEY: docker-erddap-buildx-
TOMCAT_AMD64_IMAGE: tomcat:10.1.26-jdk21-temurin-jammy@sha256:18952effb643bf192799e4ab2ca7c121d58871e96e5709fb5d405f4682a9aae7
TOMCAT_ARM64_IMAGE: tomcat:10.1.26-jdk21-temurin-jammy@sha256:4775c2227f16ee2726a35a1e97f43bfcb1a085cad23e169b1066ec9603826d8b
jobs:
build:
name: Build and test Docker Image
runs-on: ubuntu-22.04
timeout-minutes: 10
strategy:
matrix:
include:
#amd64
- platform: "linux/amd64"
tag: "jdk17-openjdk"
base: "${{ env.TOMCAT_AMD64_IMAGE }}"

Check failure on line 29 in .github/workflows/build_docker_image.yml

View workflow run for this annotation

GitHub Actions / Build Docker images

Invalid workflow file

The workflow is not valid. .github/workflows/build_docker_image.yml (Line: 29, Col: 19): Unrecognized named-value: 'env'. Located at position 1 within expression: env.TOMCAT_AMD64_IMAGE .github/workflows/build_docker_image.yml (Line: 33, Col: 19): Unrecognized named-value: 'env'. Located at position 1 within expression: env.TOMCAT_ARM64_IMAGE
#arm64/v8
- platform: "linux/arm64/v8"
tag: "jdk17-openjdk"
base: "${{ env.TOMCAT_ARM64_IMAGE }}"
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
axiom/docker-erddap
tags: |
type=raw,value=${{ matrix.tag }},prefix=latest-
type=raw,value=${{ github.event.release.tag_name }},suffix=-${{ matrix.tag }},enable=${{ github.event_name == 'release' && github.event.action == 'published' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ${ BUILDX_CACHE }
key: ${ CACHE_KEY }${{ github.sha }}
restore-keys: |
${ CACHE_KEY }
- name: Build image
uses: docker/build-push-action@v2
with:
push: false
platforms: ${{ matrix.platform }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE=${{ matrix.base }}
cache-from: type=local,src=${ BUILDX_CACHE }
cache-to: type=local,dest=${ BUILDX_CACHE }
outputs: type=docker
- name: Run Docker Image in Background
if: matrix.platform == 'linux/amd64'
run: docker run -d -p 8080:8080 ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
- name: Check that ERDDAP Docker Image will return a 200
if: matrix.platform == 'linux/amd64'
uses: ifaxity/wait-on-action@v1
timeout-minutes: 1
with:
resource: http://localhost:8080/erddap/index.html
push:
name: Push latest image to Docker Hub
runs-on: ubuntu-22.04
timeout-minutes: 10
needs: build
if: (github.event_name == 'release' && github.event.action == 'published') || (github.ref == 'refs/heads/main') && github.repository == 'axiom-data-science/docker-erddap'
strategy:
matrix:
include:
#amd64
- platform: "linux/amd64"
tag: "jdk17-openjdk"
base: "${{ env.TOMCAT_AMD64_IMAGE }}"
#arm64/v8
- platform: "linux/arm64/v8"
tag: "jdk17-openjdk"
base: "${{ env.TOMCAT_ARM64_IMAGE }}"
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
axiom/docker-erddap
tags: |
type=raw,value=${{ matrix.tag }},prefix=latest-
type=raw,value=${{ github.event.release.tag_name }},suffix=-${{ matrix.tag }},enable=${{ github.event_name == 'release' && github.event.action == 'published' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ${ BUILDX_CACHE }
key: ${ CACHE_KEY }${{ github.sha }}
restore-keys: |
${ CACHE_KEY }
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
platforms: ${{ matrix.platform }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE=${{ matrix.base }}
cache-from: type=local,src=${ BUILDX_CACHE }
cache-to: type=local,dest=${ BUILDX_CACHE }
- name: Update repo description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: axiom/docker-erddap