Skip to content

Commit

Permalink
build: Enable Docker Go Cross-compile to improve build times (#5223)
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Peter Aldershaab <[email protected]>
  • Loading branch information
lukaspj authored Jan 17, 2025
1 parent 7fa50b4 commit f3ed6c4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ ARG DEFAULT_CONFTEST_VERSION=0.56.0

# Stage 1: build artifact and download deps

FROM golang:${GOLANG_TAG} AS builder
FROM --platform=$BUILDPLATFORM golang:${GOLANG_TAG} AS builder

# These are automatically populated by Docker
ARG TARGETOS
ARG TARGETARCH

ARG ATLANTIS_VERSION=dev
ENV ATLANTIS_VERSION=${ATLANTIS_VERSION}
Expand Down Expand Up @@ -42,7 +46,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
COPY . /app
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X 'main.version=${ATLANTIS_VERSION}' -X 'main.commit=${ATLANTIS_COMMIT}' -X 'main.date=${ATLANTIS_DATE}'" -v -o atlantis .
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags "-s -w -X 'main.version=${ATLANTIS_VERSION}' -X 'main.commit=${ATLANTIS_COMMIT}' -X 'main.date=${ATLANTIS_DATE}'" -v -o atlantis .

FROM debian:${DEBIAN_TAG} AS debian-base

Expand Down

0 comments on commit f3ed6c4

Please sign in to comment.