diff --git a/util/MsSqlMigratorUtility/Dockerfile b/util/MsSqlMigratorUtility/Dockerfile index 815a53011d..ee4b6d2712 100644 --- a/util/MsSqlMigratorUtility/Dockerfile +++ b/util/MsSqlMigratorUtility/Dockerfile @@ -2,23 +2,41 @@ # Build stage # ############################################### -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS bitwarden-build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS bitwarden-build + +# Docker buildx supplies the value for this arg +ARG TARGETPLATFORM + +# Determine proper runtime value for .NET +# We put the value in a file to be read by later layers. +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + RID=linux-x64 ; \ + elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + RID=linux-arm64 ; \ + elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ + RID=linux-arm ; \ + fi \ + && echo "RID=$RID" > /tmp/rid.txt # Copy csproj files as distinct layers WORKDIR /source +COPY src/Core/*.csproj ./src/Core/ +COPY util/Migrator/*.csproj ./util/Migrator/ COPY util/MsSqlMigratorUtility/*.csproj ./util/MsSqlMigratorUtility/ # Restore MsSqlMigratorUtility project dependencies and tools WORKDIR /source/util/MsSqlMigratorUtility -RUN dotnet restore +RUN . /tmp/rid.txt && dotnet restore -r $RID # Copy required project files WORKDIR /source +COPY src/Core/. ./src/Core/ +COPY util/Migrator/. ./util/Migrator/ COPY util/MsSqlMigratorUtility/. ./util/MsSqlMigratorUtility/ -# Build Setup app +# Build MsSqlMigratorUtility app WORKDIR /source/util/MsSqlMigratorUtility -RUN dotnet publish -c release -o /app/MsSqlMigratorUtility --no-restore --no-self-contained +RUN . /tmp/rid.txt && dotnet publish -c release -o /app/MsSqlMigratorUtility --no-restore --no-self-contained -r $RID WORKDIR /app @@ -27,6 +45,7 @@ WORKDIR /app ############################################### FROM mcr.microsoft.com/dotnet/aspnet:6.0 +ARG TARGETPLATFORM LABEL com.bitwarden.product="bitwarden" # Copy app from the build stage