Skip to content

Docker

Docker #78

Workflow file for this run

name: Docker
on:
workflow_dispatch:
release:
types: [ published ]
# branches: [ master ]
tags: [ v* ]
jobs:
build_docker:
runs-on: ubuntu-latest
strategy:
matrix:
image: [nps, npc]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ${{ matrix.image }}
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.${{ matrix.image }}
platforms: linux/amd64,linux/arm,linux/arm64,linux/386,linux/ppc64le,linux/s390x
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:master
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:${{ env.RELEASE_VERSION }}
ghcr.io/${{ github.actor }}/${{ matrix.image }}:latest
ghcr.io/${{ github.actor }}/${{ matrix.image }}:master
ghcr.io/${{ github.actor }}/${{ matrix.image }}:${{ env.RELEASE_VERSION }}