Dockerfile 1.1 KB

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