Skip to content

Docker Image Build

Docker Image Build #17

name: Docker Image Build
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- "*"
- "**/docs/**"
- ".github/**"
- "!.github/workflows/docker-image-build.yml"
concurrency: docker_image_build_${{ github.ref }}
jobs:
prepare-folders:
name: Prepare Folders
uses: ./.github/workflows/prepare-folders.yml
docker:
needs: prepare-folders
runs-on: ubuntu-latest
name: Docker Build and Push
strategy:
matrix:
directories: ${{ fromJSON(needs.prepare-folders.outputs.directories) }}
environment:
name: dockerhub
url: "https://hub.docker.com/repository/docker/${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.directories }}/general"
steps:
- name: Checkout 🔔
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: metadata
name: Compute Metadata
run: |
echo "current_date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
echo "git_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
- id: docker_image
name: Build ${{ matrix.directories }}
uses: docker/build-push-action@v5
with:
context: "${{ matrix.directories }}/"
no-cache: true
push: true
tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.directories }}:latest,${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.directories }}:${{ steps.metadata.outputs.git_tag }}
platforms: linux/amd64,linux/arm64/v8
labels: |
org.opencontainers.image.title=${{ matrix.directories }}
org.opencontainers.image.url=${{ github.repositoryUrl }}
org.opencontainers.image.version=${{ steps.metadata.outputs.git_tag }}
org.opencontainers.image.created=${{ steps.metadata.outputs.current_date }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Summary
run: |
{
echo -e "# Image: ${{ fromJson(steps.docker_image.outputs.metadata)['image.name'] }}\n"
echo '<details>'
echo '<summary>Details</summary>'
echo -e '\n```'
echo -e "${{ steps.docker_image.outputs.metadata }}"
echo -e '```'
echo '</details>'
echo -e '\n'
} >> $GITHUB_STEP_SUMMARY