Make Dockerfile support fast crossbuilds
This commit is contained in:
parent
fbb0ccb5a1
commit
3dcc255965
1 changed files with 4 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
FROM alpine:3.18 AS frontend
|
FROM --platform=$BUILDPLATFORM alpine:3.18 AS frontend
|
||||||
WORKDIR /frontend
|
WORKDIR /frontend
|
||||||
|
|
||||||
RUN apk add --no-cache --no-progress nodejs-current npm
|
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?
|
#TODO: why is a second yarn pass required here?
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS backend
|
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS backend
|
||||||
|
ARG TARGETARCH
|
||||||
WORKDIR /backend
|
WORKDIR /backend
|
||||||
|
|
||||||
# copy csproj and restore as distinct layers
|
# copy csproj and restore as distinct layers
|
||||||
COPY Iceshrimp.Backend/*.csproj .
|
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 and build backend
|
||||||
COPY Iceshrimp.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:
|
# Enable globalization and time zones:
|
||||||
# https://github.com/dotnet/dotnet-docker/blob/main/samples/enable-globalization.md
|
# https://github.com/dotnet/dotnet-docker/blob/main/samples/enable-globalization.md
|
||||||
# final stage/image
|
# final stage/image
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine-composite
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine-composite
|
||||||
EXPOSE 8080
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=backend /app .
|
COPY --from=backend /app .
|
||||||
COPY --from=frontend /frontend/dist ./wwwroot
|
COPY --from=frontend /frontend/dist ./wwwroot
|
||||||
|
|
Loading…
Add table
Reference in a new issue