Skip to content

Commit

Permalink
Support release of arm64 artifacts (#42)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
altafan authored Nov 8, 2021
1 parent 4cc26dc commit 0729c02
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
39 changes: 26 additions & 13 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ builds:
- darwin
goarch:
- amd64
- arm64
binary: feederd
checksum:
name_template: "checksums.txt"
Expand Down Expand Up @@ -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
- 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
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM golang:1.15.5-buster AS builder

ARG TARGETOS
ARG TARGETARCH

WORKDIR /tdex-feeder

COPY go.mod .
Expand All @@ -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

Expand Down

0 comments on commit 0729c02

Please sign in to comment.