Skip to content

Latest commit

 

History

History
166 lines (121 loc) · 5.79 KB

DEV.md

File metadata and controls

166 lines (121 loc) · 5.79 KB

Development Guide

Docker Build and Publish

Releases

The release workflow publishes the image itself; nothing needs building locally. A v* tag builds the static (musl) Linux binaries for x86_64, arm64 and armv7 (build_linux in .github/workflows/ci.yml, published as vuio-linux-x86_64.tar.gz, vuio-linux-arm64.tar.gz and vuio-linux-armv7.tar.gz), and docker_image copies the first two into the image (FROM scratch) instead of compiling, starts each platform with host networking, checks that it drops root, serves HTTP and answers an SSDP search, and pushes ghcr.io/vuiodev/vuio with the version in both spellings and as latest (for v1.2.3: 1.2.3, v1.2.3, 1.2, latest). The Helm chart is published after it.

Every pull request runs the same two jobs without pushing. To publish the image again for an existing tag, run the workflow manually with the docker task and that tag, from that tag.

Building the image from prebuilt binaries

--build-arg VUIO_BINARY=prebuilt makes the Dockerfile copy docker-bin/vuio-amd64 and docker-bin/vuio-arm64 from the build context and skip the Rust stages entirely, so the build takes seconds:

TAG=v1.2.3
mkdir -p docker-bin
curl -sSL "https://github.com/vuiodev/vuio/releases/download/$TAG/vuio-linux-x86_64.tar.gz" | tar -xzO vuio > docker-bin/vuio-amd64
curl -sSL "https://github.com/vuiodev/vuio/releases/download/$TAG/vuio-linux-arm64.tar.gz" | tar -xzO vuio > docker-bin/vuio-arm64
chmod +x docker-bin/*

docker buildx build --platform linux/amd64,linux/arm64 --build-arg VUIO_BINARY=prebuilt -t vuio:local .
# or, with Apple's container CLI:
container build --arch amd64 --arch arm64 --build-arg VUIO_BINARY=prebuilt -t vuio:local .

The binaries must be static, as the Linux release binaries are: the image is FROM scratch, with no libc at all for anything else to load.

Building the image from source

Without VUIO_BINARY, the Dockerfile compiles the server inside the build, as docker build . from a checkout expects. It is slow, but it is the way to a trimmed image (see VUIO_CARGO_FLAGS in the Dockerfile).

The project includes a script for building from source and publishing multi-architecture Docker images to GitHub Container Registry.

Script Location

scripts/build-and-push-docker.sh ./scripts/build-and-push-docker.sh --tag v0.0.22 --platforms linux/amd64,linux/arm64

Features

  • Multi-architecture support: Builds for linux/amd64 and linux/arm64 by 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.io with 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

Platform Support

The Docker build uses rust:1-alpine as the base image, which limits the supported platforms:

  • ✅ linux/amd64 - Supported
  • ✅ linux/arm64 - Supported

Prerequisites

Before running the script, you need to:

  1. Log in to GitHub Container Registry:
echo $GITHUB_TOKEN | docker login ghcr.io -u YOUR_USERNAME --password-stdin
  1. Ensure Docker Buildx is available (usually comes with Docker Desktop or Docker 19.03+)

Usage

# 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

Script Options

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 -

What the Script Does

  1. Auto-detects GitHub username from git remote origin
  2. Validates required arguments and checks for Docker/buildx
  3. Creates or reuses a buildx builder instance for multi-arch builds
  4. Builds the Docker image for specified platforms using the Alpine-based Dockerfile
  5. Tags the image with semantic versioning (major, minor, patch, latest)
  6. Pushes all tags to GitHub Container Registry

Example Output

==========================================
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
==========================================

Pulling Published Images

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:1

Troubleshooting

Authentication 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