|
| 1 | +# 🐳 Docker Build Cloud — Multi-Platform Workflow |
| 2 | + |
| 3 | +## 🔍 Overview |
| 4 | + |
| 5 | +This reusable GitHub Actions workflow builds and pushes a multi-platform Docker image to Docker Hub using [Docker Build Cloud](https://docs.docker.com/build-cloud/) remote builders. It produces a single multi-arch manifest (e.g. `linux/amd64` + `linux/arm64`) in one job, with no QEMU emulation and no native ARM runners required. |
| 6 | + |
| 7 | +## ✨ Features |
| 8 | + |
| 9 | +- 🏗️ Multi-platform build in a single job via Docker Build Cloud's remote builders |
| 10 | +- 🔐 Authenticates to DockerHub for both registry push and DBC endpoint access |
| 11 | +- 🏷️ Tags the image with `<image-name>:<image-tag>` |
| 12 | +- 🚀 No QEMU emulation, no native ARM runners — DBC handles arch-specific builds |
| 13 | + |
| 14 | +> [!IMPORTANT] |
| 15 | +> Requires a Docker Build Cloud subscription and a builder configured in your DockerHub organization. The DockerHub PAT must have the **Build** scope to authenticate to the cloud endpoint. |
| 16 | +
|
| 17 | +## ⚙️ Inputs |
| 18 | + |
| 19 | +| Name | Description | Required | Default | |
| 20 | +| ------------------------ | --------------------------------------------------------------------------------- | -------- | -------------- | |
| 21 | +| `build-args` | Docker build arguments (multiline format: `KEY1=value1\nKEY2=value2`) | No | `""` | |
| 22 | +| `cloud-builder-endpoint` | Docker Build Cloud endpoint, format `<dbc-org>/<builder>` | Yes | - | |
| 23 | +| `context` | Path to Docker Build Context | No | `"."` | |
| 24 | +| `dockerfile` | Path to the Dockerfile (e.g. `'./Dockerfile'`, `'./docker/Dockerfile'`) | No | `"Dockerfile"` | |
| 25 | +| `image-name` | Name of Docker Image, fully qualified (e.g. `iexechub/my-image`) | Yes | - | |
| 26 | +| `image-tag` | Tag to apply to the built image (e.g. `1.0.0`, no v prefix) | Yes | - | |
| 27 | +| `platforms` | Comma-separated build platforms (e.g. `linux/amd64,linux/arm64`) | Yes | - | |
| 28 | + |
| 29 | +## 🔐 Secrets |
| 30 | + |
| 31 | +| Name | Description | Required | |
| 32 | +| -------------------- | ------------------------------------------------------------------------------------------ | -------- | |
| 33 | +| `dockerhub-username` | Username for Docker Hub authentication | Yes | |
| 34 | +| `dockerhub-password` | Personal Access Token for Docker Hub with the **Build** scope (needed for DBC endpoint) | Yes | |
| 35 | + |
| 36 | +## 💻 Example Usage |
| 37 | + |
| 38 | +```yaml |
| 39 | +name: Build and Push Release Image |
| 40 | + |
| 41 | +on: |
| 42 | + push: |
| 43 | + tags: |
| 44 | + - 'v*.*.*' |
| 45 | + |
| 46 | +jobs: |
| 47 | + build-multiplatform: |
| 48 | + uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/docker-build-cloud.yml@main # ⚠️ use tagged version here |
| 49 | + with: |
| 50 | + image-name: iexechub/my-image |
| 51 | + image-tag: ${{ github.ref_name }} |
| 52 | + platforms: linux/amd64,linux/arm64 |
| 53 | + cloud-builder-endpoint: ${{ vars.DOCKER_CLOUD_BUILDER_LABEL }} |
| 54 | + secrets: |
| 55 | + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 56 | + dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 57 | +``` |
| 58 | +
|
| 59 | +## 📝 Notes |
| 60 | +
|
| 61 | +- 🔒 The DockerHub PAT must have the **Build** scope, not just Read/Write — DBC endpoints will return `403 Forbidden` otherwise. |
| 62 | +- 🪪 The user owning the PAT must be a member of the cloud builder (Docker Hub → org → Build Cloud → builder → Members). |
| 63 | +- 🔁 Login to DockerHub MUST run before `setup-buildx-action` — the cloud driver reads `~/.docker/config.json` at bootstrap. |
| 64 | + |
| 65 | +## 🛠️ Troubleshooting |
| 66 | + |
| 67 | +- **`403 Forbidden` on Set up Docker Buildx**: PAT missing Build scope, user not a member of the cloud builder, token owner not in the builder org, malformed endpoint, or inactive DBC subscription. |
| 68 | +- **Manifest only contains one platform**: confirm `platforms` input lists every arch with commas (no spaces). |
0 commit comments