Skip to content

Commit 48ae3c7

Browse files
authored
ci: improved multi-arch build times (#685)
Modified the Dockerfiles for backend, controller, and frontend to use the `--platform=$BUILDPLATFORM` directive, enabling better compatibility for multi-platform builds. This change limits the exposure to emulation required to produce the image - ensuring the "base layer" is always built on the same architecture as the build system. This is safe: - for `controller` and `backend` because `go` build already supports cross-compilation - for `frontend` because the `webpack` config simply outputs HTML files to be including in the final state of the build. Signed-off-by: Andy Stoneberg <[email protected]>
1 parent 265db8d commit 48ae3c7

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

workspaces/backend/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use the golang image to build the application
2-
FROM golang:1.22 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.22 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

@@ -8,7 +8,7 @@ WORKDIR /workspace
88
# Copy the Go Modules manifests
99
COPY backend/go.mod backend/go.sum ./
1010

11-
# Copy controller directory
11+
# Copy controller directory
1212
COPY controller /workspace/controller
1313

1414
# Rewrite the go.mod to update the replace directive and download dependencies

workspaces/controller/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.22 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.22 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

workspaces/frontend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ---------- Builder stage ----------
2-
FROM node:20-slim AS builder
2+
FROM --platform=$BUILDPLATFORM node:20-slim AS builder
33

44
# Set working directory
55
WORKDIR /usr/src/app

0 commit comments

Comments
 (0)