From 3dcc2559657014044a438310de8a2a6ed68fb5ab Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Mon, 8 Jan 2024 18:32:33 +0100 Subject: [PATCH] Make Dockerfile support fast crossbuilds --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4fa1a5f4..09c1829b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.18 AS frontend +FROM --platform=$BUILDPLATFORM alpine:3.18 AS frontend WORKDIR /frontend RUN apk add --no-cache --no-progress nodejs-current npm @@ -15,21 +15,21 @@ RUN yarn --immutable && yarn build #TODO: why is a second yarn pass required here? FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS backend +ARG TARGETARCH WORKDIR /backend # copy csproj and restore as distinct layers COPY Iceshrimp.Backend/*.csproj . -RUN dotnet restore -a amd64 #TODO: make this configurable but defaulting to the current architecture +RUN dotnet restore -a $TARGETARCH # copy and build backend COPY Iceshrimp.Backend/. . -RUN dotnet publish --no-restore -a amd64 -o /app #TODO: make this configurable but defaulting to the current architecture +RUN dotnet publish --no-restore -a $TARGETARCH -o /app # Enable globalization and time zones: # https://github.com/dotnet/dotnet-docker/blob/main/samples/enable-globalization.md # final stage/image FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine-composite -EXPOSE 8080 WORKDIR /app COPY --from=backend /app . COPY --from=frontend /frontend/dist ./wwwroot