Skip to content

Commit

Permalink
Update samples to .NET 7 (#3989)
Browse files Browse the repository at this point in the history
  • Loading branch information
richlander authored Aug 16, 2022
1 parent 7cf01d8 commit 56f6d1d
Show file tree
Hide file tree
Showing 77 changed files with 29,018 additions and 29,097 deletions.
6 changes: 0 additions & 6 deletions README.samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ Tag | Dockerfile
dotnetapp-nanoserver-ltsc2022, dotnetapp, latest | [Dockerfile](https:/dotnet/dotnet-docker/blob/main/samples/dotnetapp/Dockerfile)
aspnetapp-nanoserver-ltsc2022, aspnetapp | [Dockerfile](https:/dotnet/dotnet-docker/blob/main/samples/aspnetapp/Dockerfile)

## Nano Server, version 20H2 amd64 Tags
Tag | Dockerfile
---------| ---------------
dotnetapp-nanoserver-20H2, dotnetapp, latest | [Dockerfile](https:/dotnet/dotnet-docker/blob/main/samples/dotnetapp/Dockerfile)
aspnetapp-nanoserver-20H2, aspnetapp | [Dockerfile](https:/dotnet/dotnet-docker/blob/main/samples/aspnetapp/Dockerfile)

## Nano Server, version 1809 amd64 Tags
Tag | Dockerfile
---------| ---------------
Expand Down
2 changes: 0 additions & 2 deletions eng/mcr-tags-metadata-templates/samples-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ $(McrTagsYmlTagGroup:dotnetapp-buster-slim-arm64v8)
$(McrTagsYmlTagGroup:aspnetapp-buster-slim-arm64v8)
$(McrTagsYmlTagGroup:dotnetapp-nanoserver-ltsc2022)
$(McrTagsYmlTagGroup:aspnetapp-nanoserver-ltsc2022)
$(McrTagsYmlTagGroup:dotnetapp-nanoserver-20H2)
$(McrTagsYmlTagGroup:aspnetapp-nanoserver-20H2)
$(McrTagsYmlTagGroup:dotnetapp-nanoserver-1809)
$(McrTagsYmlTagGroup:aspnetapp-nanoserver-1809)
33 changes: 0 additions & 33 deletions manifest.samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@
}
}
},
{
"dockerfile": "samples/dotnetapp",
"os": "windows",
"osVersion": "nanoserver-20H2",
"tags": {
"dotnetapp-nanoserver-20H2": {
"syndication": {
"repo": "dotnet/core/samples"
}
}
}
},
{
"dockerfile": "samples/dotnetapp",
"os": "windows",
Expand Down Expand Up @@ -201,27 +189,6 @@
}
]
},
{
"dockerfile": "samples/aspnetapp",
"os": "windows",
"osVersion": "nanoserver-20H2",
"tags": {
"aspnetapp-nanoserver-20H2": {
"syndication": {
"repo": "dotnet/core/samples"
}
}
},
"customBuildLegGroups": [
{
"name": "test-dependencies",
"type": "Integral",
"dependencies": [
"$(Repo:samples):dotnetapp-nanoserver-20H2"
]
}
]
},
{
"dockerfile": "samples/aspnetapp",
"os": "windows",
Expand Down
16 changes: 7 additions & 9 deletions samples/aspnetapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore
COPY aspnetapp/*.csproj .
RUN dotnet restore --use-current-runtime

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /source/aspnetapp
RUN dotnet publish -c release -o /app --no-restore
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app --use-current-runtime --self-contained false --no-restore

# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY --from=build /app ./
COPY --from=build /app .
ENTRYPOINT ["dotnet", "aspnetapp.dll"]
17 changes: 7 additions & 10 deletions samples/aspnetapp/Dockerfile.alpine-arm32
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
COPY aspnetapp/*.csproj .
RUN dotnet restore -r linux-musl-arm

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /source/aspnetapp
RUN dotnet publish -c release -o /app -r linux-musl-arm --self-contained false --no-restore
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app -r linux-musl-arm --self-contained false --no-restore

# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine-arm32v7
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine-arm32v7
WORKDIR /app
COPY --from=build /app ./
COPY --from=build /app .
ENTRYPOINT ["./aspnetapp"]

# See: https:/dotnet/announcements/issues/20
# Uncomment to enable globalization APIs (or delete)
Expand All @@ -24,5 +23,3 @@ COPY --from=build /app ./
# LC_ALL=en_US.UTF-8 \
# LANG=en_US.UTF-8
# RUN apk add --no-cache icu-libs

ENTRYPOINT ["./aspnetapp"]
17 changes: 7 additions & 10 deletions samples/aspnetapp/Dockerfile.alpine-arm64
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
COPY aspnetapp/*.csproj .
RUN dotnet restore -r linux-musl-arm64

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /source/aspnetapp
RUN dotnet publish -c release -o /app -r linux-musl-arm64 --self-contained false --no-restore
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app -r linux-musl-arm64 --self-contained false --no-restore

# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine-arm64v8
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine-arm64v8
WORKDIR /app
COPY --from=build /app ./
COPY --from=build /app .
ENTRYPOINT ["./aspnetapp"]

# See: https:/dotnet/announcements/issues/20
# Uncomment to enable globalization APIs (or delete)
Expand All @@ -24,5 +23,3 @@ COPY --from=build /app ./
# LC_ALL=en_US.UTF-8 \
# LANG=en_US.UTF-8
# RUN apk add --no-cache icu-libs

ENTRYPOINT ["./aspnetapp"]
17 changes: 7 additions & 10 deletions samples/aspnetapp/Dockerfile.alpine-x64
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
COPY aspnetapp/*.csproj .
RUN dotnet restore -r linux-musl-x64

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /source/aspnetapp
RUN dotnet publish -c release -o /app -r linux-musl-x64 --self-contained false --no-restore
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app -r linux-musl-x64 --self-contained false --no-restore

# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine-amd64
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine-amd64
WORKDIR /app
COPY --from=build /app ./
COPY --from=build /app .
ENTRYPOINT ["./aspnetapp"]

# See: https:/dotnet/announcements/issues/20
# Uncomment to enable globalization APIs (or delete)
Expand All @@ -24,5 +23,3 @@ COPY --from=build /app ./
# LC_ALL=en_US.UTF-8 \
# LANG=en_US.UTF-8
# RUN apk add --no-cache icu-libs

ENTRYPOINT ["./aspnetapp"]
17 changes: 7 additions & 10 deletions samples/aspnetapp/Dockerfile.alpine-x64-slim
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
COPY aspnetapp/*.csproj .
RUN dotnet restore -r linux-musl-x64 /p:PublishReadyToRun=true

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /source/aspnetapp
RUN dotnet publish -c release -o /app -r linux-musl-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app -r linux-musl-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true

# final stage/image
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine-amd64
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine-amd64
WORKDIR /app
COPY --from=build /app ./
COPY --from=build /app .
ENTRYPOINT ["./aspnetapp"]

# See: https:/dotnet/announcements/issues/20
# Uncomment to enable globalization APIs (or delete)
Expand All @@ -24,5 +23,3 @@ COPY --from=build /app ./
# LC_ALL=en_US.UTF-8 \
# LANG=en_US.UTF-8
# RUN apk add --no-cache icu-libs

ENTRYPOINT ["./aspnetapp"]
17 changes: 17 additions & 0 deletions samples/aspnetapp/Dockerfile.chiseled
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:7.0-jammy AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY aspnetapp/*.csproj .
RUN dotnet restore --use-current-runtime

# copy everything else and build app
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app --use-current-runtime --self-contained false --no-restore

# final stage/image
FROM mcr.microsoft.com/dotnet/nightly/aspnet:7.0-jammy-chiseled
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "aspnetapp.dll"]
16 changes: 7 additions & 9 deletions samples/aspnetapp/Dockerfile.debian-arm32
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore -r linux-arm
COPY aspnetapp/*.csproj .
RUN dotnet restore -r linux-arm

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /source/aspnetapp
RUN dotnet publish -c release -o /app -r linux-arm --self-contained false --no-restore
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app -r linux-arm --self-contained false --no-restore

# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim-arm32v7
FROM mcr.microsoft.com/dotnet/aspnet:7.0-bullseye-slim-arm32v7
WORKDIR /app
COPY --from=build /app ./
COPY --from=build /app .
ENTRYPOINT ["./aspnetapp"]
16 changes: 7 additions & 9 deletions samples/aspnetapp/Dockerfile.debian-arm64
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore -r linux-arm64
COPY aspnetapp/*.csproj .
RUN dotnet restore -r linux-arm64

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /source/aspnetapp
RUN dotnet publish -c release -o /app -r linux-arm64 --self-contained false --no-restore
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app -r linux-arm64 --self-contained false --no-restore

# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim-arm64v8
FROM mcr.microsoft.com/dotnet/aspnet:7.0-bullseye-slim-arm64v8
WORKDIR /app
COPY --from=build /app ./
COPY --from=build /app .
ENTRYPOINT ["./aspnetapp"]
16 changes: 7 additions & 9 deletions samples/aspnetapp/Dockerfile.debian-x64
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore -r linux-x64
COPY aspnetapp/*.csproj .
RUN dotnet restore -r linux-x64

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /source/aspnetapp
RUN dotnet publish -c release -o /app -r linux-x64 --self-contained false --no-restore
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app -r linux-x64 --self-contained false --no-restore

# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim-amd64
FROM mcr.microsoft.com/dotnet/aspnet:7.0-bullseye-slim-amd64
WORKDIR /app
COPY --from=build /app ./
COPY --from=build /app .
ENTRYPOINT ["./aspnetapp"]
16 changes: 7 additions & 9 deletions samples/aspnetapp/Dockerfile.debian-x64-slim
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore -r linux-x64 /p:PublishReadyToRun=true
COPY aspnetapp/*.csproj .
RUN dotnet restore -r linux-x64 /p:PublishReadyToRun=true

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /source/aspnetapp
RUN dotnet publish -c release -o /app -r linux-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app -r linux-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true

# final stage/image
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-bullseye-slim-amd64
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-bullseye-slim-amd64
WORKDIR /app
COPY --from=build /app ./
COPY --from=build /app .
ENTRYPOINT ["./aspnetapp"]
17 changes: 7 additions & 10 deletions samples/aspnetapp/Dockerfile.nanoserver-x64
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# https://hub.docker.com/_/microsoft-dotnet
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore -r win-x64
COPY aspnetapp/*.csproj .
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
COPY aspnetapp/. .
RUN dotnet publish -c Release -o /app -r win-x64 --self-contained false --no-restore

# final stage/image
# Relies on 6.0 multi-arch tag to pick the same Windows version as the host.
# Relies on 7.0 multi-arch tag to pick the same Windows version as the host.
# Alternatively, a release specific tag can be used, like: `6.0-nanoserver-ltsc2022`
# Other versions are 20H2 and 1809 (in place of the `ltsc2022` substring above)
FROM mcr.microsoft.com/dotnet/aspnet:6.0
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY --from=build /app ./
ENTRYPOINT ["aspnetapp"]
Loading

0 comments on commit 56f6d1d

Please sign in to comment.