Skip to content

armgit / lyftr

Public Imported from GitHub
0

Self-hosted fitness tracker. Log workouts, track nutrition, and monitor progress. Docker deployment, mobile-friendly.

Speed up multi-arch builds: cross-compile instead of QEMU emulation

Cawlumm302b94b151b4
diff --git a/backend/Dockerfile b/backend/Dockerfile
index 1823840..865e1b2 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -1,5 +1,8 @@
-# Stage 1: Build
-FROM golang:1.26-alpine AS builder
+# Stage 1: Build — run on host platform, cross-compile to target
+FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS builder
+
+ARG TARGETOS
+ARG TARGETARCH
WORKDIR /build
@@ -9,7 +12,7 @@ RUN go mod download
# Copy source and build a statically linked binary
COPY . .
-RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o lyftr-api .
+RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w" -o lyftr-api .
# Stage 2: Runtime
FROM alpine:3.19
diff --git a/web/Dockerfile b/web/Dockerfile
index 154feeb..19e2571 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -1,5 +1,5 @@
-# Stage 1: Build
-FROM node:20-alpine AS builder
+# Stage 1: Build — run on host platform to avoid QEMU slowness for npm/node
+FROM --platform=$BUILDPLATFORM node:20-alpine AS builder
WORKDIR /app