We are using GitHub Actions for binaries and Docker builds and sometimes we can reuse existing workflows for similar cases.
Repository contains reusable workflows which can be used across other projects.
| Workflow | File | Description |
|---|---|---|
| Docker - Reusable | docker-reusable.yml |
Docker amd64/arm64 builds |
This workflow is used for multi-arch builds and it uses native runner, because QEMU is slower.
| Variable | Description | Default |
|---|---|---|
docker_file |
Path to Dockerfile | docker/Dockerfile |
docker_build_context |
Docker build context | . |
dockerhub_repo |
DockerHub repository | durabilitylabs/test |
build_args |
Build arguments | '' |
tag_latest |
Set latest tag for Docker images | true |
tag_sha |
Set Git short commit as Docker tag | true |
tag_sha_long |
Set Git long commit as Docker tag | false |
tag_suffix |
Suffix for Docker images tag | '' |
checkout-fetch-depth |
actions/checkout fetch-depth | '' |
checkout-fetch-tags |
actions/checkout fetch-tags | '' |
checkout-submodules |
actions/checkout submodules | false |
amd64_builder |
Builder for amd64 | ubuntu-22.04 |
arm64_builder |
Builder for arm64 | ubuntu-22.04-arm |
Workflow uses DOCKERHUB_USERNAME and DOCKERHUB_TOKEN secrets to push images to the DockerHub.
Also, we can pass secrets required by build_args. For that, we should set arg with a value as a variable of the secret name
VITE_ARCHIVIST_API_URL=${VITE_ARCHIVIST_API_URL}-
If we are using non GitHub-hosted runners (for ARM builds), we should configure repository to use them.
-
Create DockerHub related secrets in the repository
DOCKERHUB_USERNAME DOCKERHUB_TOKEN
-
Add a workflow to the repository, with the content from examples and adjust for you needs
.github/workflows/docker.yml
name: Docker
on:
push:
branches:
- main
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
build-and-push:
name: Build and Push
uses: durability-labs/github-actions/.github/workflows/docker-reusable.yml@main
with:
docker_file: docker/Dockerfile
dockerhub_repo: durabilitylabs/test
build_args: |
VITE_ARCHIVIST_API_URL=${VITE_ARCHIVIST_API_URL}
VITE_GEO_IP_URL="Plain text"
tag_latest: ${{ github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/') }}
tag_suffix: 'custom'
checkout-fetch-depth: 0
checkout-fetch-tags: true
amd64_builder: ubuntu-24.04
arm64_builder: ubuntu-24.04-arm
secrets: inherit