Dockerfile 997 B

1234567891011121314151617181920212223242526
  1. # because of dotnet, we always build on amd64, and target platforms in cli
  2. # dotnet doesn't support QEMU for building or running.
  3. # (errors common in arm/v7 32bit) https://github.com/dotnet/dotnet-docker/issues/1537
  4. # https://hub.docker.com/_/microsoft-dotnet
  5. # hadolint ignore=DL3029
  6. # to build for a different platform than your host, use --platform=<platform>
  7. # for example, if you were on Intel (amd64) and wanted to build for ARM, you would use:
  8. # docker buildx build --platform "linux/arm64/v8" .
  9. FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:7.0 as build
  10. ARG TARGETPLATFORM
  11. ARG TARGETARCH
  12. ARG BUILDPLATFORM
  13. RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"
  14. WORKDIR /source
  15. COPY *.csproj .
  16. RUN dotnet restore -a $TARGETARCH
  17. COPY . .
  18. RUN dotnet publish -c release -o /app -a $TARGETARCH --self-contained false --no-restore
  19. # app image
  20. FROM mcr.microsoft.com/dotnet/runtime:7.0
  21. WORKDIR /app
  22. COPY --from=build /app .
  23. ENTRYPOINT ["dotnet", "Worker.dll"]