build multiarch images #89
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: GitHub CI | |
on: | |
pull_request: | |
branches: | |
- master | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
inputs: | |
wanted: | |
description: > | |
Build selected suites. Use "all" for all buildable suites, "active" | |
for all non-EOL suites, "eol" for all EOL-ed suites, or | |
comma-separated codenames. Default is "active". | |
type: string | |
default: 'active' | |
schedule: | |
- cron: 0 0 * * 0 | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
generate-jobs: | |
name: Generate Jobs | |
runs-on: ubuntu-latest | |
outputs: | |
codenames: ${{ steps.processing.outputs.codenames }} | |
steps: | |
- name: Debian Releases Info | |
id: debian | |
uses: vicamo/actions-library/debian-releases@v1 | |
- name: Ubuntu Releases Info | |
id: ubuntu | |
uses: vicamo/actions-library/ubuntu-releases@v1 | |
- name: Post Processing | |
id: processing | |
env: | |
DEBIAN_JSON: ${{ steps.debian.outputs.json }} | |
UBUNTU_JSON: ${{ steps.ubuntu.outputs.json }} | |
run: | | |
platforms='[ | |
["amd64", "linux/amd64"], | |
["arm", "linux/arm"], | |
["arm64", "linux/arm64/v8"], | |
["armel", "linux/arm/v5"], | |
["armhf", "linux/arm/v7"], | |
["i386", "linux/386"], | |
["loong64", "linux/loong64"], | |
["mips64el", "linux/mips64le"], | |
["ppc64el", "linux/ppc64le"], | |
["riscv64", "linux/riscv64"], | |
["s390x", "linux/s390x"], | |
["mips", "linux/mips"], | |
["mipsel", "linux/mipsle"], | |
["powerpc", "linux/ppc"], | |
["ppc64", "linux/ppc64"], | |
["s390", "linux/s390"], | |
["sparc", "linux/sparc"], | |
["sparc64", "linux/sparc64"], | |
["x32", "linux/amd64p32"], | |
["alpha", "linux/alpha"], | |
["hppa", "linux/hppa"], | |
["m68k", "linux/m68k"], | |
["sh4", "linux/sh4"] | |
]' | |
disabled_codename='["experimental"]' | |
disabled_arches='[ | |
"hurd-amd64", | |
"hurd-i386", | |
"ia64", | |
"kfreebsd-amd64", | |
"kfreebsd-i386", | |
"s390", | |
"x32" | |
]' | |
codenames="$({ echo "${DEBIAN_JSON}"; echo "${UBUNTU_JSON}"; } | | |
jq -s 'map(.[])' | | |
jq -c -M 'map(select(.codename as $c | | |
'"${disabled_codename}"' | | |
index($c) == null)) | | |
map(. as $s | | |
$s.mirrors[0].pockets[$s.codename].architectures as $da | | |
$s | | |
{ | |
"distribution":.distribution, | |
"codename":.codename, | |
"suite":.suite, | |
"active":.active, | |
"architectures":(.architectures - '"${disabled_arches}"' | | |
map({ | |
"arch":., | |
"platform":(. as $arch | | |
'"${platforms}"' | | |
map(select(.[0] == $arch))[0][1]), | |
}) | | |
tostring) | |
})')" | |
case "${{ inputs.wanted || 'sid' }}" in | |
all) ;; | |
active) | |
codenames="$(echo "${codenames}" | jq -c -M 'map(select(.active))')" | |
;; | |
eol) | |
codenames="$(echo "${codenames}" | jq -c -M 'map(select(.active | not))')" | |
;; | |
*) | |
wanted="$(echo "${{ inputs.wanted || 'sid' }}" | sed 's/ //g; s/\([^,]\+\)/"\1"/g')" | |
codenames="$(echo "${codenames}" | | |
jq -c -M 'map(. as $row | | |
['"${wanted}"'] | .[] | select($row.codename == .) | | |
$row)')" | |
;; | |
esac | |
echo "::group::Built JSON(codenames)" | |
echo "${codenames}" | jq | |
echo "::endgroup::" | |
echo "codenames=${codenames}" | tee -a "${GITHUB_OUTPUT}" | |
build: | |
needs: generate-jobs | |
strategy: | |
fail-fast: false | |
max-parallel: 1 | |
matrix: | |
include: ${{ fromJson(needs.generate-jobs.outputs.codenames) }} | |
name: Build | |
runs-on: ubuntu-latest | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
env: | |
DISTRO: ${{ matrix.distribution }} | |
CODENAME: ${{ matrix.codename }} | |
SUITE: ${{ matrix.suite }} | |
REPOSITORY: 'vicamo/buildpack-deps' | |
DRY_RUN: ${{ github.ref_name != 'main' }} | |
steps: | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
android: true | |
docker-images: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
swap-storage: true | |
- name: Setup containerd image store | |
run: | | |
echo "::group::docker daemon config" | |
{ cat /etc/docker/daemon.json || echo '{}'; } | \ | |
jq '. | .+{"features": {"containerd-snapshotter": true, "buildkit": true}}' | \ | |
sudo tee /etc/docker/daemon.json.new | |
sudo mv /etc/docker/daemon.json.new /etc/docker/daemon.json | |
echo "::endgroup::" | |
sudo systemctl restart docker | |
echo "::group::docker driver status" | |
docker info -f '{{ .DriverStatus }}' | |
echo "::endgroup::" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Apply templates | |
run: | | |
if [ ! -e "${DISTRO}/${CODENAME}/Dockerfile" ]; then | |
./versions.sh "${DISTRO}/${CODENAME}" | |
./apply-templates.sh "${DISTRO}/${CODENAME}" | |
fi | |
- name: Set up QEMU (Ubuntu) | |
run: | | |
sudo apt-get update -q | |
sudo apt-get install -yq binfmt-support qemu-user-static | |
ls -al /proc/sys/fs/binfmt_misc | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: v0.20.1 | |
- name: Login to Docker Hub | |
if: ${{ github.ref_name == 'main' }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Prepare | |
id: prepare | |
run: | | |
set -x | |
docker buildx ls | |
docker buildx inspect | |
builder_platforms_json="[$(docker buildx inspect|grep ^Platforms:|cut -d: -f2|tr -d \*|sed 's/\([^ ,]\+\)/"\1"/g')]" | |
architectures_json="$(echo '${{ matrix.architectures }}' | | |
jq -c -M 'map(select(.platform as $c | | |
'"${builder_platforms_json}"' | | |
index($c) != null) | |
)')" | |
platforms="$(echo "${architectures_json}" | jq -r 'map(.platform)|join(",")')" | |
echo "platforms=${platforms}" | tee -a "${GITHUB_OUTPUT}" | |
- name: Docker meta for curl images | |
id: meta-curl | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REPOSITORY }} | |
tags: | | |
${{ matrix.codename }}-curl | |
${{ matrix.suite && format('{0}-curl', matrix.suite) || '' }} | |
${{ matrix.suite == 'stable' && 'latest-curl' || '' }} | |
flavor: | | |
latest=false | |
env: | |
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | |
- name: Build curl images | |
id: build-curl | |
uses: docker/build-push-action@v5 | |
with: | |
annotations: ${{ contains(steps.prepare.outputs.platforms, ',') && steps.meta-curl.outputs.annotations || '' }} | |
build-args: | | |
BASEIMAGE=${{ format('vicamo/{0}:{1}', matrix.distribution, matrix.codename) }} | |
context: ${{ format('{0}/{1}/curl', matrix.distribution, matrix.codename) }} | |
labels: ${{ steps.meta-curl.outputs.labels }} | |
load: true | |
platforms: ${{ steps.prepare.outputs.platforms }} | |
provenance: false | |
pull: false | |
tags: ${{ steps.meta-curl.outputs.tags }} | |
- name: Docker meta for scm images | |
id: meta-scm | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REPOSITORY }} | |
tags: | | |
${{ matrix.codename }}-scm | |
${{ matrix.suite && format('{0}-scm', matrix.suite) || '' }} | |
${{ matrix.suite == 'stable' && 'latest-scm' || '' }} | |
flavor: | | |
latest=false | |
env: | |
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | |
- name: Build scm images | |
id: build-scm | |
uses: docker/build-push-action@v5 | |
with: | |
annotations: ${{ contains(steps.prepare.outputs.platforms, ',') && steps.meta-scm.outputs.annotations || '' }} | |
build-args: | | |
BASEIMAGE=${{ format('{0}:{1}-curl', env.REPOSITORY, matrix.codename) }} | |
context: ${{ format('{0}/{1}/scm', matrix.distribution, matrix.codename) }} | |
labels: ${{ steps.meta-scm.outputs.labels }} | |
load: true | |
platforms: ${{ steps.prepare.outputs.platforms }} | |
provenance: false | |
pull: false | |
tags: ${{ steps.meta-scm.outputs.tags }} | |
- name: Docker meta for buildpack-deps images | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REPOSITORY }} | |
tags: | | |
${{ matrix.codename }} | |
${{ matrix.suite && format('{0}', matrix.suite) || '' }} | |
flavor: | | |
latest=${{ matrix.suite == 'stable' && 'true' || 'false' }} | |
env: | |
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | |
- name: Build buildpack-deps images | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
annotations: ${{ contains(steps.prepare.outputs.platforms, ',') && steps.meta.outputs.annotations || '' }} | |
build-args: | | |
BASEIMAGE=${{ format('{0}:{1}-scm', env.REPOSITORY, matrix.codename) }} | |
context: ${{ format('{0}/{1}', matrix.distribution, matrix.codename) }} | |
labels: ${{ steps.meta.outputs.labels }} | |
load: true | |
platforms: ${{ steps.prepare.outputs.platforms }} | |
provenance: false | |
pull: false | |
tags: ${{ steps.meta.outputs.tags }} |