Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created January 4, 2024 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/0acc74e67d6693370c693937ee0bf4e7 to your computer and use it in GitHub Desktop.
Save bjoerntx/0acc74e67d6693370c693937ee0bf4e7 to your computer and use it in GitHub Desktop.
FROM mcr.microsoft.com/dotnet/aspnet:8.0-windowsservercore-ltsc2019 AS base
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2019 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["NuGetDockerApp/NuGetDockerApp.csproj", "NuGetDockerApp/"]
COPY NuGetDockerApp/nuget.config .
RUN dotnet restore "./NuGetDockerApp/./NuGetDockerApp.csproj"
COPY . .
WORKDIR "/src/NuGetDockerApp"
RUN dotnet build "./NuGetDockerApp.csproj" -c %BUILD_CONFIGURATION% -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./NuGetDockerApp.csproj" -r win-x64 -c %BUILD_CONFIGURATION% -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
# Install Visual C++ Redistributables
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "vc_redist.x64.exe"; \
Start-Process "vc_redist.x64.exe" -ArgumentList "/passive" -wait -Passthru; \
Remove-Item -Force vc_redist.x64.exe;
ENTRYPOINT ["dotnet", "NuGetDockerApp.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment