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 |
---|---|
docker_file |
Path to Dockerfile |
dockerhub_repo |
DockerHub repository |
build_args |
Build arguments |
tag_latest |
Set latest tag for Docker images |
tag_sha |
Set Git short commit as Docker tag |
tag_suffix |
Suffix for Docker images tag |
amd64_builder |
Builder for amd64 |
arm64_builder |
Builder for arm64 |
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_CODEX_API_URL=${VITE_CODEX_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:
- master
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
build-and-push:
name: Build and Push
uses: codex-storage/github-actions/.github/workflows/docker-reusable.yml@master
with:
docker_file: docker/Dockerfile
dockerhub_repo: codexstorage/test
tag_latest: ${{ github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/') }}
amd64_builder: ubuntu-24.04
build_args: |
VITE_CODEX_API_URL=${VITE_CODEX_API_URL}
VITE_GEO_IP_URL="Plain text"
secrets: inherit