Dockerfile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 BUILDPLATFORM
  12. RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"
  13. WORKDIR /source
  14. COPY *.csproj .
  15. RUN case ${TARGETPLATFORM} in \
  16. "linux/amd64") ARCH=x64 ;; \
  17. "linux/arm64") ARCH=arm64 ;; \
  18. "linux/arm64/v8") ARCH=arm64 ;; \
  19. "linux/arm/v7") ARCH=arm ;; \
  20. esac \
  21. && dotnet restore -r linux-${ARCH}
  22. COPY . .
  23. RUN case ${TARGETPLATFORM} in \
  24. "linux/amd64") ARCH=x64 ;; \
  25. "linux/arm64") ARCH=arm64 ;; \
  26. "linux/arm64/v8") ARCH=arm64 ;; \
  27. "linux/arm/v7") ARCH=arm ;; \
  28. esac \
  29. && dotnet publish -c release -o /app -r linux-${ARCH} --self-contained false --no-restore
  30. # app image
  31. FROM mcr.microsoft.com/dotnet/runtime:7.0
  32. WORKDIR /app
  33. COPY --from=build /app .
  34. ENTRYPOINT ["dotnet", "Worker.dll"]