From adae6ebe2fb6b39f3e26b33f0b97ac6e46dea8bf Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 30 Jan 2026 22:25:46 +0100 Subject: [PATCH] Update Dockerfile to only compile Rust once on amd64 (#1531) --- apps/server/AliasVault.Client/Dockerfile | 4 +++- dockerfiles/all-in-one/Dockerfile | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/server/AliasVault.Client/Dockerfile b/apps/server/AliasVault.Client/Dockerfile index d09401a79..e1837db76 100644 --- a/apps/server/AliasVault.Client/Dockerfile +++ b/apps/server/AliasVault.Client/Dockerfile @@ -4,7 +4,9 @@ WORKDIR /app # ============================================ # Stage: Build core libraries # ============================================ -FROM rust:1-slim-bookworm AS core-builder +# Use BUILDPLATFORM to run on native arch (amd64) instead of emulating arm64. +# WASM output is platform-independent, so we only need to build once. +FROM --platform=$BUILDPLATFORM rust:1-slim-bookworm AS core-builder # Install Node.js and wasm-pack (Rust already included in base image) RUN apt-get update && \ diff --git a/dockerfiles/all-in-one/Dockerfile b/dockerfiles/all-in-one/Dockerfile index d8199f390..36c7f8421 100644 --- a/dockerfiles/all-in-one/Dockerfile +++ b/dockerfiles/all-in-one/Dockerfile @@ -3,7 +3,9 @@ # ============================================ # Stage 1: Build core libraries # ============================================ -FROM rust:1-slim-bookworm AS core-builder +# Use BUILDPLATFORM to run on native arch (amd64) instead of emulating arm64. +# WASM output is platform-independent, so we only need to build once. +FROM --platform=$BUILDPLATFORM rust:1-slim-bookworm AS core-builder # Install Node.js and wasm-pack (Rust already included in base image) RUN apt-get update && \ @@ -28,7 +30,9 @@ RUN cd ./core && \ # ============================================ # Stage 2: Build .NET applications # ============================================ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS dotnet-builder +# Use BUILDPLATFORM for .NET build - the published output is architecture-independent +# (Blazor WASM runs in browser, server components use IL that runs anywhere) +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS dotnet-builder # Install Python (required for WASM compilation) and Node.js (required by JS bundler) RUN apt-get update && \