Skip to content

Docker Build

Docker Build #138

Workflow file for this run

name: Docker Build
on:
push:
branches:
- main
tags:
- '*'
workflow_dispatch:
inputs:
tag:
description: 'Docker image tag'
required: true
default: 'nightly'
jobs:
prepare:
name: Prepare Docker Metadata
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
${{ github.repository }}
tags: |
type=raw,value=${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_type == 'tag' && github.ref_name || 'nightly' }}
type=sha,format=short
build-and-push:
name: Build and push Docker image
needs: prepare
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ needs.prepare.outputs.tags }}
labels: ${{ needs.prepare.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max