diff --git a/.github/workflows/upload-docker.yml b/.github/workflows/upload-docker.yml index 8a18fdd..122266a 100644 --- a/.github/workflows/upload-docker.yml +++ b/.github/workflows/upload-docker.yml @@ -15,6 +15,9 @@ jobs: - name: Log payload run: echo "Received tag:\ ${{ github.event.client_payload.tag }}" + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -24,15 +27,22 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push Docker image + - name: Prepare tags + id: prep run: | TAG=${{ github.event.client_payload.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_image/ - docker push canopynetwork/canopy:${DOCKER_TAG} - docker push canopynetwork/canopy:latest + echo "docker_tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: ./docker_image/ + platforms: linux/amd64,linux/arm64 + push: true + tags: | + canopynetwork/canopy:${{ steps.prep.outputs.docker_tag }} + canopynetwork/canopy:latest + build-args: | + BRANCH=${{ github.event.client_payload.tag }} + BUILD_PATH=cmd/cli diff --git a/README.md b/README.md index 751b910..915f0d2 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,16 @@ For more information please refer to [Monitoring stack README.md](./monitoring-s It contains the [Dockerfile]([url](https://github.com/canopy-network/deployments/tree/master/docker_image)) and entrypoint.sh used by all the stacks in order to have a centralized way of building the canopy image +##### Multi-architecture support + +The Docker image supports both `amd64` and `arm64` architectures. When building via the GitHub Actions workflow, images are automatically built for both platforms and published as a multi-arch manifest. + +For multi-platform builds locally using Docker Buildx: + +```bash +docker buildx build --platform linux/amd64,linux/arm64 -t canopynetwork/canopy:local ./docker_image/ +``` + #### Canopy config files diff --git a/docker_image/Dockerfile b/docker_image/Dockerfile index 2220833..cae2a85 100644 --- a/docker_image/Dockerfile +++ b/docker_image/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