The project includes a script for building and publishing multi-architecture Docker images to GitHub Container Registry.
scripts/build-and-push-docker.sh
./scripts/build-and-push-docker.sh --tag v0.0.22 --platforms linux/amd64,linux/arm64
- Multi-architecture support: Builds for
linux/amd64andlinux/arm64by default - Automatic tagging: Creates semantic version tags (e.g.,
v1.2.3,1.2.3,1.2,1,latest) - GitHub Container Registry: Publishes to
ghcr.iowith auto-detection of your GitHub username - Build optimizations: Supports cache control and custom platforms
- User-friendly: Color-coded output, progress messages, and comprehensive error handling
The Docker build uses rust:1-alpine as the base image, which limits the supported platforms:
- ✅
linux/amd64- Supported - ✅
linux/arm64- Supported
Before running the script, you need to:
- Log in to GitHub Container Registry:
echo $GITHUB_TOKEN | docker login ghcr.io -u YOUR_USERNAME --password-stdin- Ensure Docker Buildx is available (usually comes with Docker Desktop or Docker 19.03+)
# Basic usage - build and push a version
./scripts/build-and-push-docker.sh --tag v1.0.0
# Build for single platform only (faster for testing)
./scripts/build-and-push-docker.sh --tag v1.2.3 --platforms linux/amd64
# Build without cache
./scripts/build-and-push-docker.sh --tag v2.0.0 --no-cache
# Skip 'latest' tag
./scripts/build-and-push-docker.sh --tag v1.0.0-beta --no-latest
# Custom GitHub user/org
./scripts/build-and-push-docker.sh --tag v1.0.0 --user myorganization
# View help
./scripts/build-and-push-docker.sh --help| Option | Description | Default |
|---|---|---|
-t, --tag TAG |
Version tag (e.g., v1.0.0) | Required |
-u, --user USER |
GitHub username/organization | Auto-detected from git |
-r, --registry URL |
Container registry URL | ghcr.io |
-p, --platforms ARCH |
Platforms to build | linux/amd64,linux/arm64 |
--no-cache |
Build without cache | Uses cache |
--no-latest |
Don't tag as 'latest' | Tags as latest |
-h, --help |
Show help message | - |
- Auto-detects GitHub username from git remote origin
- Validates required arguments and checks for Docker/buildx
- Creates or reuses a buildx builder instance for multi-arch builds
- Builds the Docker image for specified platforms using the Alpine-based Dockerfile
- Tags the image with semantic versioning (major, minor, patch, latest)
- Pushes all tags to GitHub Container Registry
==========================================
Docker Multi-Arch Build & Push
==========================================
Project: vuio
Tag: v1.0.0
Version: 1.0.0
Registry: ghcr.io
User: yourusername
Image: ghcr.io/yourusername/vuio
Platforms: linux/amd64,linux/arm64
Tag latest: true
==========================================
After successful publication, you can pull images with:
# Specific version
docker pull ghcr.io/yourusername/vuio:1.0.0
# Latest version
docker pull ghcr.io/yourusername/vuio:latest
# Major version
docker pull ghcr.io/yourusername/vuio:1Authentication errors: Ensure you're logged in to ghcr.io with a valid GitHub token that has write:packages permission
Buildx not found: Update Docker to version 19.03+ or install buildx plugin
Platform not supported: Check that QEMU is set up for cross-platform builds:
docker run --privileged --rm tonistiigi/binfmt --install all