Skip to content

Commit

Permalink
Dockerfile update for multi-arch building.
Browse files Browse the repository at this point in the history
  • Loading branch information
GinoCanessa committed Sep 3, 2024
1 parent 0b02044 commit f117c6b
Showing 1 changed file with 3 additions and 36 deletions.
39 changes: 3 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETARCH
Expand All @@ -9,43 +9,10 @@ WORKDIR /app
COPY . ./

RUN dotnet restore -a $TARGETARCH src/fhir-candle/fhir-candle.csproj
#RUN dotnet build -a $TARGETARCH src/fhir-candle/fhir-candle.csproj -c Release -o out
RUN dotnet publish -a $TARGETARCH src/fhir-candle/fhir-candle.csproj -c Release -o out

#
## Build with platform-specific .Net RID
#RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch x64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch x64; \
#elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch arm64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch arm64; \
#elif [ "$TARGETPLATFORM" = "windows/x64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch x64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch x64; \
#elif [ "$TARGETPLATFORM" = "windows/arm64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch arm64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch arm64; \
#elif [ "$TARGETPLATFORM" = "darwin/x64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch x64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch x64; \
#elif [ "$TARGETPLATFORM" = "darwin/arm64" ]; then \
#dotnet restore src/fhir-candle/fhir-candle.csproj --arch arm64; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0 --arch arm64; \
#else \
##echo "Unsupported architecture: $TARGETPLATFORM"; \
##exit 1; \
#dotnet restore src/fhir-candle/fhir-candle.csproj; \
#dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0; \
#fi;

#RUN dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out --framework net8.0;
#RUN dotnet restore src/fhir-candle/fhir-candle.csproj
#RUN dotnet publish src/fhir-candle/fhir-candle.csproj -c Release -o out

RUN dotnet publish -a $TARGETARCH src/fhir-candle/fhir-candle.csproj -c Release -o out --no-restore

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "fhir-candle.dll"]
Expand Down

0 comments on commit f117c6b

Please sign in to comment.