Support ARM multi-arch build in Dockerfile

This commit is contained in:
Anduin
2026-02-22 06:27:05 +00:00
parent 26bd6beac6
commit 0c2afb62d3
+12 -3
View File
@@ -5,7 +5,7 @@ ARG FRONT_END_PATH="${CSPROJ_PATH}/wwwroot"
# ============================ # ============================
# Prepare node modules # Prepare node modules
# ============================ # ============================
FROM hub.aiursoft.com/node:24-alpine AS npm-env FROM --platform=$BUILDPLATFORM hub.aiursoft.com/node:24-alpine AS npm-env
ARG FRONT_END_PATH ARG FRONT_END_PATH
WORKDIR /src WORKDIR /src
@@ -20,14 +20,23 @@ RUN npm install --loglevel verbose --force
# ============================ # ============================
# Prepare .NET binaries # Prepare .NET binaries
# ============================ # ============================
FROM hub.aiursoft.com/aiursoft/internalimages/dotnet AS build-env FROM --platform=$BUILDPLATFORM hub.aiursoft.com/aiursoft/internalimages/dotnet AS build-env
ARG CSPROJ_PATH ARG CSPROJ_PATH
ARG PROJ_NAME ARG PROJ_NAME
ARG TARGETARCH
WORKDIR /src WORKDIR /src
# Build # Build
COPY . . COPY . .
RUN dotnet publish ${CSPROJ_PATH}/${PROJ_NAME}.csproj --configuration Release --no-self-contained --runtime linux-x64 --output /app RUN if [ "$TARGETARCH" = "arm64" ]; then \
RID="linux-arm64"; \
elif [ "$TARGETARCH" = "amd64" ]; then \
RID="linux-x64"; \
else \
RID="linux-$TARGETARCH"; \
fi && \
echo "Building for arch: $TARGETARCH, using .NET RID: $RID" && \
dotnet publish ${CSPROJ_PATH}/${PROJ_NAME}.csproj --configuration Release --no-self-contained --runtime $RID --output /app
# ============================ # ============================
# Prepare runtime image # Prepare runtime image