From a7b8743c6231c73cb2431f4af7672ad09c98bc09 Mon Sep 17 00:00:00 2001 From: Pablo Date: Mon, 13 Jul 2026 19:02:23 -0400 Subject: [PATCH] feat: add multi arch support for docker --- .docker/auto-update/Dockerfile | 5 +- .docker/auto-update/Dockerfile.csharp | 5 +- .docker/auto-update/Dockerfile.go | 5 +- .docker/auto-update/Dockerfile.kotlin | 5 +- .docker/auto-update/Dockerfile.python | 5 +- .docker/auto-update/Dockerfile.typescript | 5 +- .github/workflows/release.yml | 178 +++++++++++++++------- 7 files changed, 137 insertions(+), 71 deletions(-) diff --git a/.docker/auto-update/Dockerfile b/.docker/auto-update/Dockerfile index 83406d7499..8da6a233e1 100644 --- a/.docker/auto-update/Dockerfile +++ b/.docker/auto-update/Dockerfile @@ -6,6 +6,7 @@ ARG BUILD_PATH=cmd/cli ARG GO_BIN_DIR ARG BUILD_LOCAL=False ARG BIN_PATH=/bin/cli +ARG TARGETARCH # downloads git and clones selected version RUN apk add --no-cache git ca-certificates alpine-sdk @@ -32,12 +33,12 @@ RUN make build/wallet RUN make build/explorer # Builds auto-update CLI -RUN CGO_ENABLED=0 GOOS=linux go build -a -o bin ./cmd/auto-update/. +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o bin ./cmd/auto-update/. # Only build if the file at ${BIN_PATH} doesn't already exist RUN if [ ! -f "${BIN_PATH}" ]; then \ echo "File ${BIN_PATH} not found. Building it..."; \ - CGO_ENABLED=0 GOOS=linux go build -a -o "${BIN_PATH}" ./cmd/main/...; \ + CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o "${BIN_PATH}" ./cmd/main/...; \ else \ echo "File ${BIN_PATH} already exists. Skipping build."; \ fi diff --git a/.docker/auto-update/Dockerfile.csharp b/.docker/auto-update/Dockerfile.csharp index 486c04ffeb..ed7e5671fa 100644 --- a/.docker/auto-update/Dockerfile.csharp +++ b/.docker/auto-update/Dockerfile.csharp @@ -2,6 +2,7 @@ FROM node:24-alpine AS builder ARG BRANCH='latest' ARG BIN_PATH=/bin/cli +ARG TARGETARCH # Install build dependencies RUN apk add --no-cache git ca-certificates alpine-sdk @@ -35,10 +36,10 @@ RUN make build/wallet RUN make build/explorer # Build auto-update coordinator -RUN CGO_ENABLED=0 GOOS=linux go build -a -o bin ./cmd/auto-update/. +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o bin ./cmd/auto-update/. # Build CLI -RUN CGO_ENABLED=0 GOOS=linux go build -a -o "${BIN_PATH}" ./cmd/main/... +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o "${BIN_PATH}" ./cmd/main/... # ============================================================================= # Final image for C# plugin diff --git a/.docker/auto-update/Dockerfile.go b/.docker/auto-update/Dockerfile.go index 3fad92df94..9e8d69afae 100644 --- a/.docker/auto-update/Dockerfile.go +++ b/.docker/auto-update/Dockerfile.go @@ -2,6 +2,7 @@ FROM node:24-alpine AS builder ARG BRANCH='latest' ARG BIN_PATH=/bin/cli +ARG TARGETARCH # Install build dependencies RUN apk add --no-cache git ca-certificates alpine-sdk @@ -35,10 +36,10 @@ RUN make build/wallet RUN make build/explorer # Build auto-update coordinator -RUN CGO_ENABLED=0 GOOS=linux go build -a -o bin ./cmd/auto-update/. +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o bin ./cmd/auto-update/. # Build CLI -RUN CGO_ENABLED=0 GOOS=linux go build -a -o "${BIN_PATH}" ./cmd/main/... +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o "${BIN_PATH}" ./cmd/main/... # ============================================================================= # Final image for Go plugin diff --git a/.docker/auto-update/Dockerfile.kotlin b/.docker/auto-update/Dockerfile.kotlin index aa0e19edee..d599411c0e 100644 --- a/.docker/auto-update/Dockerfile.kotlin +++ b/.docker/auto-update/Dockerfile.kotlin @@ -2,6 +2,7 @@ FROM node:24-alpine AS builder ARG BRANCH='latest' ARG BIN_PATH=/bin/cli +ARG TARGETARCH # Install build dependencies RUN apk add --no-cache git ca-certificates alpine-sdk @@ -35,10 +36,10 @@ RUN make build/wallet RUN make build/explorer # Build auto-update coordinator -RUN CGO_ENABLED=0 GOOS=linux go build -a -o bin ./cmd/auto-update/. +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o bin ./cmd/auto-update/. # Build CLI -RUN CGO_ENABLED=0 GOOS=linux go build -a -o "${BIN_PATH}" ./cmd/main/... +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o "${BIN_PATH}" ./cmd/main/... # ============================================================================= # Final image for Kotlin plugin diff --git a/.docker/auto-update/Dockerfile.python b/.docker/auto-update/Dockerfile.python index a28c111d58..71f273e080 100644 --- a/.docker/auto-update/Dockerfile.python +++ b/.docker/auto-update/Dockerfile.python @@ -2,6 +2,7 @@ FROM node:24-alpine AS builder ARG BRANCH='latest' ARG BIN_PATH=/bin/cli +ARG TARGETARCH # Install build dependencies RUN apk add --no-cache git ca-certificates alpine-sdk @@ -35,10 +36,10 @@ RUN make build/wallet RUN make build/explorer # Build auto-update coordinator -RUN CGO_ENABLED=0 GOOS=linux go build -a -o bin ./cmd/auto-update/. +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o bin ./cmd/auto-update/. # Build CLI -RUN CGO_ENABLED=0 GOOS=linux go build -a -o "${BIN_PATH}" ./cmd/main/... +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o "${BIN_PATH}" ./cmd/main/... # ============================================================================= # Final image for Python plugin diff --git a/.docker/auto-update/Dockerfile.typescript b/.docker/auto-update/Dockerfile.typescript index 4be04ef635..2da7d7040b 100644 --- a/.docker/auto-update/Dockerfile.typescript +++ b/.docker/auto-update/Dockerfile.typescript @@ -2,6 +2,7 @@ FROM node:24-alpine AS builder ARG BRANCH='latest' ARG BIN_PATH=/bin/cli +ARG TARGETARCH # Install build dependencies RUN apk add --no-cache git ca-certificates alpine-sdk @@ -35,10 +36,10 @@ RUN make build/wallet RUN make build/explorer # Build auto-update coordinator -RUN CGO_ENABLED=0 GOOS=linux go build -a -o bin ./cmd/auto-update/. +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o bin ./cmd/auto-update/. # Build CLI -RUN CGO_ENABLED=0 GOOS=linux go build -a -o "${BIN_PATH}" ./cmd/main/... +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o "${BIN_PATH}" ./cmd/main/... # ============================================================================= # Final image for TypeScript plugin diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0fd8259686..f3ca325d75 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,6 +58,9 @@ jobs: with: ref: ${{ github.ref }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -67,18 +70,25 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push + - name: Prepare tags + id: prep run: | TAG=${{ github.event.inputs.tag }} DOCKER_TAG=${TAG//+/-} - docker build \ - -t canopynetwork/canopy:${DOCKER_TAG} \ - -t canopynetwork/canopy:latest \ - --build-arg BRANCH=${TAG} \ - --build-arg BUILD_PATH=cmd/cli \ - ./.docker/auto-update/ - docker push canopynetwork/canopy:${DOCKER_TAG} - docker push canopynetwork/canopy:latest + echo "docker_tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./.docker/auto-update/ + platforms: linux/amd64,linux/arm64 + push: true + tags: | + canopynetwork/canopy:${{ steps.prep.outputs.docker_tag }} + canopynetwork/canopy:latest + build-args: | + BRANCH=${{ github.event.inputs.tag }} + BUILD_PATH=cmd/cli docker-go: name: Docker - Go Plugin @@ -91,6 +101,9 @@ jobs: with: ref: ${{ github.ref }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -100,19 +113,26 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push + - name: Prepare tags + id: prep run: | TAG=${{ github.event.inputs.tag }} DOCKER_TAG=${TAG//+/-} - docker build \ - -t canopynetwork/canopy:go-${DOCKER_TAG} \ - -t canopynetwork/canopy:go-latest \ - --build-arg BRANCH=${TAG} \ - --build-arg BUILD_PATH=cmd/cli \ - -f ./.docker/auto-update/Dockerfile.go \ - ./.docker/auto-update/ - docker push canopynetwork/canopy:go-${DOCKER_TAG} - docker push canopynetwork/canopy:go-latest + echo "docker_tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./.docker/auto-update/ + file: ./.docker/auto-update/Dockerfile.go + platforms: linux/amd64,linux/arm64 + push: true + tags: | + canopynetwork/canopy:go-${{ steps.prep.outputs.docker_tag }} + canopynetwork/canopy:go-latest + build-args: | + BRANCH=${{ github.event.inputs.tag }} + BUILD_PATH=cmd/cli docker-python: name: Docker - Python Plugin @@ -125,6 +145,9 @@ jobs: with: ref: ${{ github.ref }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -134,19 +157,26 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push + - name: Prepare tags + id: prep run: | TAG=${{ github.event.inputs.tag }} DOCKER_TAG=${TAG//+/-} - docker build \ - -t canopynetwork/canopy:python-${DOCKER_TAG} \ - -t canopynetwork/canopy:python-latest \ - --build-arg BRANCH=${TAG} \ - --build-arg BUILD_PATH=cmd/cli \ - -f ./.docker/auto-update/Dockerfile.python \ - ./.docker/auto-update/ - docker push canopynetwork/canopy:python-${DOCKER_TAG} - docker push canopynetwork/canopy:python-latest + echo "docker_tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./.docker/auto-update/ + file: ./.docker/auto-update/Dockerfile.python + platforms: linux/amd64,linux/arm64 + push: true + tags: | + canopynetwork/canopy:python-${{ steps.prep.outputs.docker_tag }} + canopynetwork/canopy:python-latest + build-args: | + BRANCH=${{ github.event.inputs.tag }} + BUILD_PATH=cmd/cli docker-typescript: name: Docker - TypeScript Plugin @@ -159,6 +189,9 @@ jobs: with: ref: ${{ github.ref }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -168,19 +201,26 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push + - name: Prepare tags + id: prep run: | TAG=${{ github.event.inputs.tag }} DOCKER_TAG=${TAG//+/-} - docker build \ - -t canopynetwork/canopy:typescript-${DOCKER_TAG} \ - -t canopynetwork/canopy:typescript-latest \ - --build-arg BRANCH=${TAG} \ - --build-arg BUILD_PATH=cmd/cli \ - -f ./.docker/auto-update/Dockerfile.typescript \ - ./.docker/auto-update/ - docker push canopynetwork/canopy:typescript-${DOCKER_TAG} - docker push canopynetwork/canopy:typescript-latest + echo "docker_tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./.docker/auto-update/ + file: ./.docker/auto-update/Dockerfile.typescript + platforms: linux/amd64,linux/arm64 + push: true + tags: | + canopynetwork/canopy:typescript-${{ steps.prep.outputs.docker_tag }} + canopynetwork/canopy:typescript-latest + build-args: | + BRANCH=${{ github.event.inputs.tag }} + BUILD_PATH=cmd/cli docker-kotlin: name: Docker - Kotlin Plugin @@ -193,6 +233,9 @@ jobs: with: ref: ${{ github.ref }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -202,19 +245,26 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push + - name: Prepare tags + id: prep run: | TAG=${{ github.event.inputs.tag }} DOCKER_TAG=${TAG//+/-} - docker build \ - -t canopynetwork/canopy:kotlin-${DOCKER_TAG} \ - -t canopynetwork/canopy:kotlin-latest \ - --build-arg BRANCH=${TAG} \ - --build-arg BUILD_PATH=cmd/cli \ - -f ./.docker/auto-update/Dockerfile.kotlin \ - ./.docker/auto-update/ - docker push canopynetwork/canopy:kotlin-${DOCKER_TAG} - docker push canopynetwork/canopy:kotlin-latest + echo "docker_tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./.docker/auto-update/ + file: ./.docker/auto-update/Dockerfile.kotlin + platforms: linux/amd64,linux/arm64 + push: true + tags: | + canopynetwork/canopy:kotlin-${{ steps.prep.outputs.docker_tag }} + canopynetwork/canopy:kotlin-latest + build-args: | + BRANCH=${{ github.event.inputs.tag }} + BUILD_PATH=cmd/cli docker-csharp: name: Docker - C# Plugin @@ -227,6 +277,9 @@ jobs: with: ref: ${{ github.ref }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -236,16 +289,23 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push + - name: Prepare tags + id: prep run: | TAG=${{ github.event.inputs.tag }} DOCKER_TAG=${TAG//+/-} - docker build \ - -t canopynetwork/canopy:csharp-${DOCKER_TAG} \ - -t canopynetwork/canopy:csharp-latest \ - --build-arg BRANCH=${TAG} \ - --build-arg BUILD_PATH=cmd/cli \ - -f ./.docker/auto-update/Dockerfile.csharp \ - ./.docker/auto-update/ - docker push canopynetwork/canopy:csharp-${DOCKER_TAG} - docker push canopynetwork/canopy:csharp-latest + echo "docker_tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: ./.docker/auto-update/ + file: ./.docker/auto-update/Dockerfile.csharp + platforms: linux/amd64,linux/arm64 + push: true + tags: | + canopynetwork/canopy:csharp-${{ steps.prep.outputs.docker_tag }} + canopynetwork/canopy:csharp-latest + build-args: | + BRANCH=${{ github.event.inputs.tag }} + BUILD_PATH=cmd/cli