Skip to content

Commit d517697

Browse files
committed
make multiarch images
1 parent f65ed5a commit d517697

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

.github/workflows/docker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
uses: docker/build-push-action@v2
6363
with:
6464
context: .
65+
platforms: linux/amd64,linux/arm64
6566
push: ${{ github.event_name != 'pull_request' }}
6667
tags: ${{ steps.meta.outputs.tags }}
6768
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
FROM golang:1.26 AS build
1+
FROM --platform=$BUILDPLATFORM golang:1.26 AS build
2+
3+
ARG TARGETOS
4+
ARG TARGETARCH
25

36
WORKDIR /go/src/app
47
COPY . .
58

6-
RUN make
9+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make
710

811
FROM debian:bookworm-slim
912

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ clean:
1313
rm bin/site || :
1414

1515
build:
16-
go build -o bin/$(NAME) \
16+
CGO_ENABLED=0 go build -o bin/$(NAME) \
1717
-ldflags "-X '$(pkg)/pkg/version.Commit=$(git_commit)' -X '$(pkg)/pkg/version.Date=$(date)' -X '$(pkg)/pkg/version.Version=$(git_tag)'" \
1818
$(PACKAGE)/cmd
1919

@@ -24,7 +24,7 @@ dev: build
2424
@bin/site
2525

2626
docker:
27-
docker build -t byxorna/site:$(git_tag) .
27+
docker buildx build --platform linux/amd64,linux/arm64 -t byxorna/site:$(git_tag) .
2828

2929
pprof-heap: build
3030
go tool pprof http://localhost:6060/debug/pprof/heap

0 commit comments

Comments
 (0)