From 0729c023ccf1c93e9cc2932d684a07a70821aa0a Mon Sep 17 00:00:00 2001 From: Pietralberto Mazza Date: Mon, 8 Nov 2021 17:48:46 +0100 Subject: [PATCH] Support release of arm64 artifacts (#42) * Add arm64 artifacts to releaser * Add TARGETOS and TARGETARCH args to Dockerfile * Fix gh-action release workflow * Remove unused build args * Try to remove permissions --- .github/workflows/release.yml | 7 +++++++ .goreleaser.yml | 39 +++++++++++++++++++++++------------ Dockerfile | 5 ++++- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8226e2..888acda 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,11 +7,18 @@ on: jobs: goreleaser: runs-on: ubuntu-latest + env: + DOCKER_CLI_EXPERIMENTAL: "enabled" + steps: - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Go uses: actions/setup-go@v2 with: diff --git a/.goreleaser.yml b/.goreleaser.yml index 818bc77..0b574a4 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -8,6 +8,7 @@ builds: - darwin goarch: - amd64 + - arm64 binary: feederd checksum: name_template: "checksums.txt" @@ -40,53 +41,65 @@ archives: dockers: # push always either release or prerelease with a docker tag with the semver only + # amd64 - skip_push: false dockerfile: Dockerfile + use: buildx # image templates image_templates: - - "ghcr.io/tdex-network/feederd:{{ .Tag }}" + - "ghcr.io/tdex-network/feederd:{{ .Tag }}-amd64" # GOOS of the built binaries/packages that should be used. goos: linux # GOARCH of the built binaries/packages that should be used. goarch: amd64 # Template of the docker build flags. build_flag_templates: + - "--platform=linux/amd64" - "--pull" - "--label=org.opencontainers.image.created={{.Date}}" - "--label=org.opencontainers.image.title={{.ProjectName}}" - "--label=org.opencontainers.image.revision={{.FullCommit}}" - "--label=org.opencontainers.image.version={{.Version}}" - - "--build-arg=VERSION={{.Version}}" - - "--build-arg=COMMIT={{.Commit}}" - - "--build-arg=DATE={{.Date}}" - extra_files: - go.mod - go.sum - internal - cmd - # push only release with both a docker tag latest and one with the semver - - skip_push: auto + + # arm64 + - skip_push: false dockerfile: Dockerfile + use: buildx # image templates image_templates: - - "ghcr.io/tdex-network/feederd:latest" + - "ghcr.io/tdex-network/feederd:{{ .Tag }}-arm64v8" # GOOS of the built binaries/packages that should be used. goos: linux # GOARCH of the built binaries/packages that should be used. - goarch: amd64 + goarch: arm64 # Template of the docker build flags. build_flag_templates: + - "--platform=linux/arm64/v8" - "--pull" - "--label=org.opencontainers.image.created={{.Date}}" - "--label=org.opencontainers.image.title={{.ProjectName}}" - "--label=org.opencontainers.image.revision={{.FullCommit}}" - "--label=org.opencontainers.image.version={{.Version}}" - - "--build-arg=VERSION={{.Version}}" - - "--build-arg=COMMIT={{.Commit}}" - - "--build-arg=DATE={{.Date}}" extra_files: - go.mod - go.sum - internal - - cmd \ No newline at end of file + - cmd + +docker_manifests: + - name_template: ghcr.io/tdex-network/feederd:{{ .Tag }} + image_templates: + - ghcr.io/tdex-network/feederd:{{ .Tag }}-amd64 + - ghcr.io/tdex-network/feederd:{{ .Tag }}-arm64v8 + skip_push: false + + - name_template: ghcr.io/tdex-network/feederd:latest + image_templates: + - ghcr.io/tdex-network/feederd:{{ .Tag }}-amd64 + - ghcr.io/tdex-network/feederd:{{ .Tag }}-arm64v8 + skip_push: auto \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6c0c381..ba60862 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM golang:1.15.5-buster AS builder +ARG TARGETOS +ARG TARGETARCH + WORKDIR /tdex-feeder COPY go.mod . @@ -8,7 +11,7 @@ RUN go mod download COPY . . -RUN GOOS=linux GOARCH=amd64 go build -o feederd-linux cmd/feederd/main.go +RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o feederd-linux cmd/feederd/main.go WORKDIR /build