Skip to content

Commit

Permalink
build multi-arch docker image via goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
odyfey committed Jul 6, 2024
1 parent 5677930 commit 7375466
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ jobs:
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Docker login
env:
GITHUB_REGISTRY_TOKEN: ${{ secrets.GHCR_TOKEN }}
run: echo ${GITHUB_REGISTRY_TOKEN} | docker login ghcr.io -u odyfey --password-stdin

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
Expand Down
25 changes: 25 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,28 @@ archives:
- format: tar.gz
files:
- LICENSE

dockers:
- image_templates:
- &amd_image 'ghcr.io/odyfey/tern:{{ .Tag }}-amd64'
use: buildx
build_flag_templates:
- "--push"
- "--platform=linux/amd64"
- image_templates:
- &arm_image 'ghcr.io/odyfey/tern:{{ .Tag }}-arm64'
use: buildx
build_flag_templates:
- "--push"
- "--platform=linux/arm64"
goarch: arm64

docker_manifests:
- name_template: 'ghcr.io/odyfey/tern:{{ .Tag }}'
image_templates:
- *amd_image
- *arm_image
- name_template: 'ghcr.io/odyfey/tern:latest'
image_templates:
- *amd_image
- *arm_image
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.22-alpine as build

ENV CGO_ENABLED=0

WORKDIR /build

COPY go.* ./
COPY *.go ./
COPY migrate ./migrate

RUN go build -o tern

FROM alpine:3.20
COPY --from=build /build/tern /tern
ENTRYPOINT ["/tern"]

0 comments on commit 7375466

Please sign in to comment.