Create a .crt
file in the root of the API project that contains the CA certificates.
Use the following Dockerfile configuration:
FROM mcr.microsoft.com/dotnet/sdk:latest AS base
WORKDIR /app
COPY . .
RUN dotnet nuget add source /app/nuget_packages -n "local"
RUN dotnet nuget remove source "nuget.org"
RUN dotnet publish -c Release -o out
RUN mv <cert-file>.crt /app/out
FROM mcr.microsoft.com/dotnet/aspnet:latest
EXPOSE 80
EXPOSE 443
ENV ASPNETCORE_HTTP_PORTS=80
WORKDIR /app
COPY --from=base /app/out .
RUN mv <cert-file>.crt /usr/local/share/ca-certificates
RUN chmod 644 /usr/local/share/ca-certificates/<cert-file>.crt && update-ca-certificates
ENTRYPOINT ["dotnet", "<API>.dll"]