I'm trying to use Visual Studio 2019 to develop a ASP.NET Core 3.1 app running in Docker for Windows. I'm having a few problems with this. I need to host an endpoint to start and stop a service and provide some health check info. The services are installed from a third-party MSI (I'd love to just copy files over, but we don't want to run it unsupported, plus it's files and registry changes). The basic (dotnet/sdk, /core, and /aspnet) images are based on Nano Server so don't support MSI/msiexec. I've tried a large number of images to find one that supports ASP.Net Core plus msiexec (Server Core), but it seems like only the large images fit our needs (8+ GB vs <500MB for the Nano ones). Is there another possibility here? At this point, I can't even get the build to work consistently. Files will build but not end up in the final image, and if they make it I can't seem to hit them (trying ports 80/443, 5000/5001, or the actual Docker-exposed ports, with localhost or the container's IP address). It's getting pretty frustrating! I'd love any help.
- Finding a reasonably-sized image that supports ASP.net Core 3.1 and msiexec
- Build process to properly publish and copy files to the final image
- Service to be accessible from outside the container.
Current dockerfile:
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
# INSTALL dotnet
ADD https://download.visualstudio.microsoft.com/download/pr/c37ece76-1305-4042-a9e6-58e7cb1b0bf6/75c20ff59335e370985b4f03fa637fcb/aspnetcore-runtime-3.1.18-win-x64.exe /symedical/
ADD https://download.visualstudio.microsoft.com/download/pr/7d09d7c0-8902-4467-9268-d7f584923cde/eddcb12257e68b030bc1b4baf9a68681/dotnet-runtime-3.1.18-win-x64.exe /symedical/
RUN C:/symedical/aspnetcore-runtime-3.1.18-win-x64.exe /install /quiet /norestart && \
C:/symedical/dotnet-runtime-3.1.18-win-x64.exe /install /quiet
ARG InstallerSrc="dist/installers/ThirdPartyClientServices.msi"
ARG InstallerDest="/install/"
ADD ${InstallerSrc} ${InstallerDest}
ARG InstallerSrc="dist/scripts/"
ADD ${InstallerSrc} ${InstallerDest}
RUN powershell -file "c:\dist\scripts\install-msi.ps1"
######
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["Distribution/Distribution.csproj", "Distribution/"]
RUN dotnet restore "Distribution/Distribution.csproj"
COPY . .
WORKDIR "/src/Distribution"
RUN dotnet build "Distribution.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Distribution.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Distribution.dll"]