Skip to content

Commit

Permalink
Speedup Go multi-arch compilation for other images
Browse files Browse the repository at this point in the history
  • Loading branch information
PKizzle committed Nov 1, 2023
1 parent 9ce2354 commit f237485
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions proxy.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ COPY web .
RUN npm run build-proxy

# Stage 2: Build
FROM docker.io/golang:1.21.3-bookworm AS builder
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.21.3-bookworm AS builder

ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

ARG GOOS=$TARGETOS
ARG GOARCH=$TARGETARCH

WORKDIR /go/src/goauthentik.io

Expand All @@ -29,7 +36,7 @@ ENV CGO_ENABLED=0
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o /go/proxy ./cmd/proxy
GOARM="${TARGETVARIANT#v}" go build -o /go/proxy ./cmd/proxy

# Stage 3: Run
FROM gcr.io/distroless/static-debian11:debug
Expand Down
11 changes: 9 additions & 2 deletions radius.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Stage 1: Build
FROM docker.io/golang:1.21.3-bookworm AS builder
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.21.3-bookworm AS builder

ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

ARG GOOS=$TARGETOS
ARG GOARCH=$TARGETARCH

WORKDIR /go/src/goauthentik.io

Expand All @@ -13,7 +20,7 @@ ENV CGO_ENABLED=0
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o /go/radius ./cmd/radius
GOARM="${TARGETVARIANT#v}" go build -o /go/radius ./cmd/radius

# Stage 2: Run
FROM gcr.io/distroless/static-debian11:debug
Expand Down

0 comments on commit f237485

Please sign in to comment.