forked from dotnet/dotnet-docker
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample Dockerfiles for Windows Server Core (dotnet#2428)
- Loading branch information
Showing
6 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# https://hub.docker.com/_/microsoft-dotnet | ||
FROM mcr.microsoft.com/dotnet/sdk:5.0-windowsservercore-ltsc2019 AS build | ||
WORKDIR /source | ||
|
||
# copy csproj and restore as distinct layers | ||
COPY *.sln . | ||
COPY aspnetapp/*.csproj ./aspnetapp/ | ||
RUN dotnet restore -r win-x64 | ||
|
||
# copy everything else and build app | ||
COPY aspnetapp/. ./aspnetapp/ | ||
WORKDIR /source/aspnetapp | ||
RUN dotnet publish -c release -o /app -r win-x64 --self-contained false --no-restore | ||
|
||
# final stage/image | ||
FROM mcr.microsoft.com/dotnet/aspnet:5.0-windowsservercore-ltsc2019 AS runtime | ||
WORKDIR /app | ||
COPY --from=build /app ./ | ||
ENTRYPOINT ["aspnetapp"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# escape=` | ||
|
||
# https://hub.docker.com/_/microsoft-dotnet | ||
FROM mcr.microsoft.com/dotnet/sdk:5.0-windowsservercore-ltsc2019 AS build | ||
WORKDIR /source | ||
|
||
# copy csproj and restore as distinct layers | ||
COPY *.sln . | ||
COPY aspnetapp/*.csproj ./aspnetapp/ | ||
RUN dotnet restore -r win-x64 | ||
|
||
# copy everything else and build app | ||
COPY aspnetapp/. ./aspnetapp/ | ||
WORKDIR /source/aspnetapp | ||
RUN dotnet publish -c release -o /app -r win-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true | ||
|
||
# final stage/image | ||
# Uses the ltsc2019 release; 20H2, 2004, 1909, 1809, and ltsc2016 are other choices | ||
FROM mcr.microsoft.com/windows/servercore:ltsc2019 AS runtime | ||
WORKDIR /app | ||
COPY --from=build /app ./ | ||
|
||
ENV ` | ||
# Configure web servers to bind to port 80 when present | ||
ASPNETCORE_URLS=http://+:80 ` | ||
# Enable detection of running in a container | ||
DOTNET_RUNNING_IN_CONTAINER=true | ||
|
||
ENTRYPOINT ["aspnetapp"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://hub.docker.com/_/microsoft-dotnet | ||
FROM mcr.microsoft.com/dotnet/sdk:5.0-windowsservercore-ltsc2019 AS build | ||
WORKDIR /source | ||
|
||
# copy csproj and restore as distinct layers | ||
COPY *.csproj . | ||
RUN dotnet restore -r win-x64 | ||
|
||
# copy and publish app and libraries | ||
COPY . . | ||
RUN dotnet publish -c release -o /app -r win-x64 --self-contained false --no-restore | ||
|
||
# final stage/image | ||
FROM mcr.microsoft.com/dotnet/runtime:5.0-windowsservercore-ltsc2019 | ||
WORKDIR /app | ||
COPY --from=build /app . | ||
ENTRYPOINT ["dotnetapp"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# https://hub.docker.com/_/microsoft-dotnet | ||
FROM mcr.microsoft.com/dotnet/sdk:5.0-windowsservercore-ltsc2019 AS build | ||
WORKDIR /source | ||
|
||
# copy csproj and restore as distinct layers | ||
COPY *.csproj . | ||
RUN dotnet restore -r win-x64 | ||
|
||
# copy and publish app and libraries | ||
COPY . . | ||
RUN dotnet publish -c release -o /app -r win-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true | ||
|
||
# final stage/image | ||
# Uses the ltsc2019 release; 20H2, 2004, 1909, 1809, and ltsc2016 are other choices | ||
FROM mcr.microsoft.com/windows/servercore:ltsc2019 | ||
WORKDIR /app | ||
COPY --from=build /app . | ||
|
||
# Enable detection of running in a container | ||
ENV DOTNET_RUNNING_IN_CONTAINER=true | ||
|
||
ENTRYPOINT ["dotnetapp"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters