From 2bf088b4a9e0bf76d83102433c3e2b5f512f7829 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Sun, 22 Jun 2025 16:59:21 -0400 Subject: [PATCH] feat: speed up docker build --- CHANGELOG.md | 1 + Dockerfile | 14 ++++++++++---- package.json | 4 ++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd803da..9829b30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - You may need to run `chown -R 65532:65532 ` on your data directory to ensure the container can write to it. - Removing a Split DNS record will no longer make the split domain unresolvable by clients (closes [#231](https://github.com/tale/headplane/issues/231)). - Reintroduce the toggle for overriding local DNS settings in the Headscale config (closes [#236](https://github.com/tale/headplane/issues/236)). +- Prefer cross-compiling in the Dockerfile to speed up builds while still supporting multiple architectures. ### 0.6.0 (May 25, 2025) - Headplane 0.6.0 now requires **Headscale 0.26.0** or newer. diff --git a/Dockerfile b/Dockerfile index 9baccb9..a224d81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,23 @@ -FROM jdxcode/mise:latest AS mise-context +FROM --platform=$BUILDPLATFORM jdxcode/mise:latest AS mise-context COPY mise.toml . RUN mise install -FROM mise-context AS go-build +FROM --platform=$BUILDPLATFORM mise-context AS go-build WORKDIR /build/ COPY go.mod go.sum ./ COPY cmd/ ./cmd/ COPY internal/ ./internal/ -RUN mkdir -p /build/app/ && mise run wasm ::: agent + +ARG TARGETOS +ARG TARGETARCH +RUN mkdir -p /build/app/ && \ + GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 \ + mise run wasm ::: agent + RUN chmod +x /build/build/hp_agent -FROM mise-context AS js-build +FROM --platform=$BUILDPLATFORM mise-context AS js-build WORKDIR /build COPY patches ./patches COPY package.json pnpm-lock.yaml ./ diff --git a/package.json b/package.json index f58624f..592081b 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,10 @@ "patchedDependencies": { "react-router-hono-server": "patches/react-router-hono-server.patch" }, + "supportedArchitectures": { + "os": ["current", "linux"], + "cpu": ["x64", "arm64"] + }, "onlyBuiltDependencies": [ "@biomejs/biome", "better-sqlite3",