Skip to content

Commit fea6c80

Browse files
committed
build: use cross-compilation build instead of emulated build for faster docker build
for more information: https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
1 parent 2e86ad5 commit fea6c80

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
##
44
## Build
55
##
6-
FROM golang:1.20-bookworm AS build
6+
FROM --platform=$BUILDPLATFORM golang:1.20-bookworm AS build
77

8+
ARG TARGETOS TARGETARCH
89
ARG BUILD_WITH_COVERAGE
910
ARG BUILD_SNAPSHOT=true
1011

@@ -16,7 +17,7 @@ RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' > /etc/apt/sourc
1617

1718
COPY . .
1819

19-
RUN goreleaser build --snapshot="${BUILD_SNAPSHOT}" --single-target -o extension \
20+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH goreleaser build --snapshot="${BUILD_SNAPSHOT}" --single-target -o extension \
2021
&& setcap "cap_sys_boot,cap_sys_time,cap_setuid,cap_setgid,cap_net_raw,cap_net_admin,cap_sys_admin,cap_dac_override+eip" ./extension
2122

2223

0 commit comments

Comments
 (0)