Skip to content

Add CrossGen2 Dockerfiles for the various options we want to perf test #1818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 5 additions & 95 deletions 5.0/aspnet/alpine3.11/amd64/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,101 +1,11 @@
ARG REPO=mcr.microsoft.com/dotnet/core/runtime-deps

# Create standard image
FROM $REPO:5.0-alpine3.11 AS StandardImage

# Install .NET Core

RUN dotnet_version=5.0.0-preview.2.20160.6 \
&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Runtime/$dotnet_version/dotnet-runtime-$dotnet_version-linux-musl-x64.tar.gz \
&& dotnet_sha512='f8dcf9f498feffbca4b0649086cffd298cd98189b2950c32dd52b07179b7f33e1acfe14ae59a266502a3518089ca55f224e007628d16194f94be7dc419c1b2b4' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet.tar.gz
ARG REPO=mcr.microsoft.com/dotnet/core/runtime
FROM $REPO:5.0-alpine3.11

# Install ASP.NET Core
RUN aspnetcore_version=5.0.0-preview.2.20167.3 \
&& wget -O aspnetcore.tar.gz https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/$aspnetcore_version/aspnetcore-runtime-$aspnetcore_version-linux-musl-x64.tar.gz \
ENV ASPNET_VERSION 5.0.0-preview.2.20167.3

RUN wget -O aspnetcore.tar.gz https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/$ASPNET_VERSION/aspnetcore-runtime-$ASPNET_VERSION-linux-musl-x64.tar.gz \
&& aspnetcore_sha512='029ed32f8a7dfdb258438177b7fd40c187830db35b3d973dec296d8948f99d30a74269c45d31876c9b4533b8d7b6af65dea319299bd9a7081c6881cf026274b4' \
&& echo "$aspnetcore_sha512 aspnetcore.tar.gz" | sha512sum -c - \
&& tar -ozxf aspnetcore.tar.gz -C /usr/share/dotnet ./shared/Microsoft.AspNetCore.App \
&& rm aspnetcore.tar.gz

RUN dotnet --list-runtimes

# CROSSGEN the binaries from the standard image
FROM $REPO:5.0-alpine3.11 AS SdkImage

ENV \
# Unset the value from the base image
ASPNETCORE_URLS= \
# Disable the invariant mode (set in base image)
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
# Enable correct mode for dotnet watch (only mode supported in a container)
DOTNET_USE_POLLING_FILE_WATCHER=true \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
# Skip extraction of XML docs - generally not useful within an image/container - helps performance
NUGET_XMLDOC_MODE=skip \
# PowerShell telemetry for docker image usage
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetCoreSDK-Alpine-3.10

# Add dependencies for disabling invariant mode (set in base image)
RUN apk add --no-cache icu-libs

# Install .NET Core SDK
RUN dotnet_sdk_version=5.0.100-preview.2.20175.2 \
&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-musl-x64.tar.gz \
&& dotnet_sha512='07b2e91410306297d7d8ccd84aa00be06181efb8cb3cc4fab57cd370aca65409ba59c87dba70d2b46e1dd05c0597c2f0c8f38cde35032910febb08f51b65731a' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet.tar.gz \
# Trigger first run experience by running arbitrary cmd
&& dotnet help

# Install PowerShell global tool
RUN powershell_version=7.0.0 \
&& wget -O PowerShell.Linux.Alpine.$powershell_version.nupkg https://pwshtool.blob.core.windows.net/tool/$powershell_version/PowerShell.Linux.Alpine.$powershell_version.nupkg \
&& powershell_sha512='afca5d8553d612e36d04597de14cdba9731442d567d25fb9b0f1451116f299f773b4f49b5be7d4d89e3e874eb43f8c062ae70c2ed1d620244a2a52ba443cf4cb' \
&& echo "$powershell_sha512 PowerShell.Linux.Alpine.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.Alpine \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.Alpine.$powershell_version.nupkg \
&& chmod 755 /usr/share/powershell/pwsh \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
# To reduce image size, remove the copy nupkg that nuget keeps.
&& find /usr/share/powershell -print | grep -i '.*[.]nupkg$' | xargs rm \
# Add ncurses-terminfo-base to resolve psreadline dependency
&& apk add --no-cache ncurses-terminfo-base

RUN dotnet --list-runtimes
RUN dotnet --list-sdks

RUN dotnet --list-runtimes | grep Microsoft.NETCore.App | cut -d ' ' -f 2 > runtime-version.txt
RUN dotnet --list-runtimes | grep Microsoft.AspNetCore.App | cut -d ' ' -f 2 > aspnet-version.txt

RUN dotnet new console -o /tmp
COPY nuget.config /tmp
RUN dotnet publish /tmp/tmp.csproj -p:PublishReadyToRun=true -p:PublishReadyToRunUseCrossgen2=true -r linux-musl-x64
COPY --from=StandardImage /usr/share/dotnet/shared/Microsoft.NETCore.App /usr/cpinput
COPY --from=StandardImage /usr/share/dotnet/shared/Microsoft.AspNetCore.App /usr/cpaspinput
RUN mkdir /usr/input
RUN cp /usr/cpinput/$(cat runtime-version.txt)/*.dll /usr/input
RUN cp /usr/cpaspinput/$(cat aspnet-version.txt)/*.dll /usr/input
RUN mkdir /usr/crossgen2
RUN ~/.nuget/packages/microsoft.netcore.app.crossgen2.linux-musl-x64/$(cat runtime-version.txt)/tools/crossgen2 --inputbubble -o /usr/crossgen2/sharedframework.dll --composite -O --Os /usr/input/*.dll

COPY --from=StandardImage /usr/share/dotnet /usr/output
RUN for b in /usr/output/shared/Microsoft.NETCore.App/$(cat runtime-version.txt)/*.dll; do a=/usr/crossgen2/`basename ${b}`; test -e ${a} && cp ${a} /usr/output/shared/Microsoft.NETCore.App/$(cat runtime-version.txt); done
RUN for b in /usr/output/shared/Microsoft.AspNetCore.App/$(cat aspnet-version.txt)/*.dll; do a=/usr/crossgen2/`basename ${b}`; test -e ${a} && cp ${a} /usr/output/shared/Microsoft.AspNetCore.App/$(cat aspnet-version.txt); done
RUN cp /usr/crossgen2/sharedframework.dll /usr/output/shared/Microsoft.NETCore.App/$(cat runtime-version.txt)

# Create optimized monolithic docker image
FROM $REPO:5.0-alpine3.11

COPY --from=SdkImage /usr/output /usr/share/dotnet
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
39 changes: 39 additions & 0 deletions 5.0/aspnet/alpine3.11/amd64/composed-composite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# TODO: define a shared base stage (build infra doesn't support)
ARG REPO=mcr.microsoft.com/dotnet/core/runtime


# Installer image
FROM $REPO:5.0-alpine3.11-composite as installer

# Install crossgen2
RUN wget -O crossgen2.tar.gz https://dotnetbinaries.blob.core.windows.net/dockerassets/microsoft.netcore.app.crossgen2.linux-musl-x64.$DOTNET_VERSION.tar.gz \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary solution I built and uploaded until we get on a build that includes the official crossgen2 artifacts - dotnet/runtime#34623

&& crossgen2_sha512='6beecdd14e52d48b8e794b73dab4b148a50744c1a50f1108c1c30bc1df20fb2cd1741359e7a3f3803e8576ef166308b0d558a18ea6456b343586056025b63e1c' \
&& echo "$crossgen2_sha512 crossgen2.tar.gz" | sha512sum -c - \
&& mkdir /crossgen2 \
&& tar -C /crossgen2 -oxzf crossgen2.tar.gz \
&& rm crossgen2.tar.gz

ENV ASPNET_VERSION 5.0.0-preview.2.20167.3

RUN \
# Retrieve ASP.NET
wget -O aspnetcore.tar.gz https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/$ASPNET_VERSION/aspnetcore-runtime-$ASPNET_VERSION-linux-musl-x64.tar.gz \
&&aspnetcore_sha512='029ed32f8a7dfdb258438177b7fd40c187830db35b3d973dec296d8948f99d30a74269c45d31876c9b4533b8d7b6af65dea319299bd9a7081c6881cf026274b4' \
&& echo "$aspnetcore_sha512 aspnetcore.tar.gz" | sha512sum -c - \
&& tar -ozxf aspnetcore.tar.gz -C /usr/share/dotnet ./shared/Microsoft.AspNetCore.App \
&& rm aspnetcore.tar.gz \
\
# Crossgen .NET Core
&& /crossgen2/crossgen2 \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidwrighton - can you help me out with the correct crossgen2 build args here?

This is for the following scenario:

I see a fourth option which is the runtime uses composite images and aspnet does as well, but they do not use a unified composite image, but rather one built locally to the particular image.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need a -r argument to reference the runtime level bits. So, add an argument like -r /dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/*.dll to the command line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, does the change to publish crossgen2 binaries work? I wasn't able to test the end to end scenario without checking in.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @davidwrighton for the guidance on which args to use. I did run into an issue with the arg which I am not sure if it is a known issue or something wrong with my usage. I had issues when -r was specified just before the input-files. The following Dockerfile snippets illustrate what I mean.

Broken - error regarding no input-files specified

    # Crossgen .NET Core
    && /crossgen2/crossgen2 \
        --composite --inputbubble -O --Os \
        -o /usr/share/dotnet/shared/Microsoft.AspNetCore.App/$ASPNET_VERSION/Microsoft.AspNetCore.App.SharedFramework.dll \
        -r /usr/share/dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/*.dll \
        /usr/share/dotnet/shared/Microsoft.AspNetCore.App/$ASPNET_VERSION/*.dll

Working

    # Crossgen .NET Core
    && /crossgen2/crossgen2 \
        --composite --inputbubble -O --Os \
        -r /usr/share/dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/*.dll \
        -o /usr/share/dotnet/shared/Microsoft.AspNetCore.App/$ASPNET_VERSION/Microsoft.AspNetCore.App.SharedFramework.dll \
        /usr/share/dotnet/shared/Microsoft.AspNetCore.App/$ASPNET_VERSION/*.dll

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, does the change to publish crossgen2 binaries work

I hooked-up the docker unit tests which run an e2e app scenario. The tests are passing which is encouraging.

--composite --inputbubble -O --Os \
-r /usr/share/dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/*.dll \
-o /usr/share/dotnet/shared/Microsoft.AspNetCore.App/$ASPNET_VERSION/Microsoft.AspNetCore.App.SharedFramework.dll \
/usr/share/dotnet/shared/Microsoft.AspNetCore.App/$ASPNET_VERSION/*.dll


# ASP.NET Core image
FROM $REPO:5.0-alpine3.11-composite

ENV ASPNET_VERSION 5.0.0-preview.2.20167.3

COPY --from=installer ["/usr/share/dotnet/shared/Microsoft.AspNetCore.App", "/usr/share/dotnet/shared/Microsoft.AspNetCore.App"]
59 changes: 59 additions & 0 deletions 5.0/aspnet/alpine3.11/amd64/composite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# TODO: define a shared base stage (build infra doesn't support)
ARG REPO=mcr.microsoft.com/dotnet/core/runtime-deps


# Installer image
FROM $REPO:5.0-alpine3.11 as installer

ENV DOTNET_VERSION 5.0.0-preview.2.20160.6

# Install crossgen2
RUN wget -O crossgen2.tar.gz https://dotnetbinaries.blob.core.windows.net/dockerassets/microsoft.netcore.app.crossgen2.linux-musl-x64.$DOTNET_VERSION.tar.gz \
&& crossgen2_sha512='6beecdd14e52d48b8e794b73dab4b148a50744c1a50f1108c1c30bc1df20fb2cd1741359e7a3f3803e8576ef166308b0d558a18ea6456b343586056025b63e1c' \
&& echo "$crossgen2_sha512 crossgen2.tar.gz" | sha512sum -c - \
&& mkdir /crossgen2 \
&& tar -C /crossgen2 -oxzf crossgen2.tar.gz \
&& rm crossgen2.tar.gz

ENV ASPNET_VERSION 5.0.0-preview.2.20167.3

RUN \
# Retrieve .NET and ASP.NET
wget -O aspnetcore.tar.gz https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/$ASPNET_VERSION/aspnetcore-runtime-$ASPNET_VERSION-linux-musl-x64.tar.gz \
&& aspnetcore_sha512='029ed32f8a7dfdb258438177b7fd40c187830db35b3d973dec296d8948f99d30a74269c45d31876c9b4533b8d7b6af65dea319299bd9a7081c6881cf026274b4' \
&& echo "$aspnetcore_sha512 aspnetcore.tar.gz" | sha512sum -c - \
&& mkdir /dotnet \
&& tar -C /dotnet -ozxf aspnetcore.tar.gz \
&& rm aspnetcore.tar.gz \
\
# Crossgen .NET Core
&& mkdir -p /work/input \
&& cp /dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/*.dll /work/input \
&& cp /dotnet/shared/Microsoft.AspNetCore.App/$ASPNET_VERSION/*.dll /work/input \
&& mkdir -p /work/output \
&& /crossgen2/crossgen2 \
--composite --inputbubble -O --Os \
-o /work/output/Microsoft.AspNetCore.App.SharedFramework.dll \
/work/input/*.dll \
&& for b in /dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/*.dll; \
do \
a=/work/output/`basename ${b}`; \
test -e ${a} && cp ${a} /dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION; \
done \
&& for b in /dotnet/shared/Microsoft.AspNetCore.App/$ASPNET_VERSION/*.dll; \
do \
a=/work/output/`basename ${b}`; \
test -e ${a} && cp ${a} /dotnet/shared/Microsoft.AspNetCore.App/$ASPNET_VERSION; \
done \
&& cp /work/output/Microsoft.AspNetCore.App.SharedFramework.dll /dotnet/shared/Microsoft.AspNetCore.App/$ASPNET_VERSION \
&& rm -r /work


# ASP.NET image
FROM $REPO:5.0-alpine3.11

ENV DOTNET_VERSION=5.0.0-preview.2.20160.6 \
ASPNET_VERSION=5.0.0-preview.2.20167.3

COPY --from=installer ["/dotnet", "/usr/share/dotnet"]
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
12 changes: 0 additions & 12 deletions 5.0/aspnet/alpine3.11/amd64/nuget.config

This file was deleted.

11 changes: 11 additions & 0 deletions 5.0/aspnet/alpine3.11/amd64/runtime-composite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG REPO=mcr.microsoft.com/dotnet/core/runtime
FROM $REPO:5.0-alpine3.11-composite

# Install ASP.NET Core
ENV ASPNET_VERSION 5.0.0-preview.2.20167.3

RUN wget -O aspnetcore.tar.gz https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/$ASPNET_VERSION/aspnetcore-runtime-$ASPNET_VERSION-linux-musl-x64.tar.gz \
&& aspnetcore_sha512='029ed32f8a7dfdb258438177b7fd40c187830db35b3d973dec296d8948f99d30a74269c45d31876c9b4533b8d7b6af65dea319299bd9a7081c6881cf026274b4' \
&& echo "$aspnetcore_sha512 aspnetcore.tar.gz" | sha512sum -c - \
&& tar -ozxf aspnetcore.tar.gz -C /usr/share/dotnet ./shared/Microsoft.AspNetCore.App \
&& rm aspnetcore.tar.gz
5 changes: 3 additions & 2 deletions 5.0/runtime/alpine3.11/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ ARG REPO=mcr.microsoft.com/dotnet/core/runtime-deps
FROM $REPO:5.0-alpine3.11

# Install .NET Core
RUN dotnet_version=5.0.0-preview.2.20160.6 \
&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Runtime/$dotnet_version/dotnet-runtime-$dotnet_version-linux-musl-x64.tar.gz \
ENV DOTNET_VERSION 5.0.0-preview.2.20160.6

RUN wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-$DOTNET_VERSION-linux-musl-x64.tar.gz \
&& dotnet_sha512='f8dcf9f498feffbca4b0649086cffd298cd98189b2950c32dd52b07179b7f33e1acfe14ae59a266502a3518089ca55f224e007628d16194f94be7dc419c1b2b4' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
Expand Down
41 changes: 41 additions & 0 deletions 5.0/runtime/alpine3.11/amd64/composite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# TODO: define a shared base stage (build infra doesn't support)
ARG REPO=mcr.microsoft.com/dotnet/core/runtime-deps


# Installer image
FROM $REPO:5.0-alpine3.11 as installer

ENV DOTNET_VERSION 5.0.0-preview.2.20160.6

# Install crossgen2
RUN wget -O crossgen2.tar.gz https://dotnetbinaries.blob.core.windows.net/dockerassets/microsoft.netcore.app.crossgen2.linux-musl-x64.$DOTNET_VERSION.tar.gz \
&& crossgen2_sha512='6beecdd14e52d48b8e794b73dab4b148a50744c1a50f1108c1c30bc1df20fb2cd1741359e7a3f3803e8576ef166308b0d558a18ea6456b343586056025b63e1c' \
&& echo "$crossgen2_sha512 crossgen2.tar.gz" | sha512sum -c - \
&& mkdir /crossgen2 \
&& tar -C /crossgen2 -oxzf crossgen2.tar.gz \
&& rm crossgen2.tar.gz


RUN \
# Retrieve .NET
wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-$DOTNET_VERSION-linux-musl-x64.tar.gz \
&& dotnet_sha512='f8dcf9f498feffbca4b0649086cffd298cd98189b2950c32dd52b07179b7f33e1acfe14ae59a266502a3518089ca55f224e007628d16194f94be7dc419c1b2b4' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir /dotnet \
&& tar -C /dotnet -oxzf dotnet.tar.gz \
&& rm dotnet.tar.gz \
\
# Crossgen .NET
&& /crossgen2/crossgen2 \
--composite --inputbubble -O --Os \
-o /dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/Microsoft.NETCore.App.SharedFramework.dll \
/dotnet/shared/Microsoft.NETCore.App/$DOTNET_VERSION/*.dll


# .NET runtime image
FROM $REPO:5.0-alpine3.11

ENV DOTNET_VERSION 5.0.0-preview.2.20160.6

COPY --from=installer ["/dotnet", "/usr/share/dotnet"]
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
4 changes: 2 additions & 2 deletions 5.0/sdk/alpine3.11/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM $REPO:5.0-alpine3.11
ENV \
# Unset the value from the base image
ASPNETCORE_URLS= \
DOTNET_SDK_VERSION=5.0.100-preview.2.20175.2 \
# Disable the invariant mode (set in base image)
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
# Enable correct mode for dotnet watch (only mode supported in a container)
Expand All @@ -19,8 +20,7 @@ ENV \
RUN apk add --no-cache icu-libs

# Install .NET Core SDK
RUN dotnet_sdk_version=5.0.100-preview.2.20175.2 \
&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-musl-x64.tar.gz \
RUN wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-musl-x64.tar.gz \
&& dotnet_sha512='07b2e91410306297d7d8ccd84aa00be06181efb8cb3cc4fab57cd370aca65409ba59c87dba70d2b46e1dd05c0597c2f0c8f38cde35032910febb08f51b65731a' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
Expand Down
46 changes: 46 additions & 0 deletions 5.0/sdk/alpine3.11/amd64/aspnet-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
ARG REPO=mcr.microsoft.com/dotnet/core/aspnet
FROM $REPO:5.0-alpine3.11

ENV \
# Unset the value from the base image
ASPNETCORE_URLS= \
DOTNET_SDK_VERSION=5.0.100-preview.2.20175.2 \
# Disable the invariant mode (set in base image)
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
# Enable correct mode for dotnet watch (only mode supported in a container)
DOTNET_USE_POLLING_FILE_WATCHER=true \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
# Skip extraction of XML docs - generally not useful within an image/container - helps performance
NUGET_XMLDOC_MODE=skip \
# PowerShell telemetry for docker image usage
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetCoreSDK-Alpine-3.10

# Add dependencies for disabling invariant mode (set in base image)
RUN apk add --no-cache icu-libs

# Install .NET Core SDK
RUN wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-musl-x64.tar.gz \
&& dotnet_sha512='07b2e91410306297d7d8ccd84aa00be06181efb8cb3cc4fab57cd370aca65409ba59c87dba70d2b46e1dd05c0597c2f0c8f38cde35032910febb08f51b65731a' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -ozxf dotnet.tar.gz -C /usr/share/dotnet ./packs ./sdk ./templates \
&& rm dotnet.tar.gz \
# Trigger first run experience by running arbitrary cmd
&& dotnet help

# Install PowerShell global tool
RUN powershell_version=7.0.0 \
&& wget -O PowerShell.Linux.Alpine.$powershell_version.nupkg https://pwshtool.blob.core.windows.net/tool/$powershell_version/PowerShell.Linux.Alpine.$powershell_version.nupkg \
&& powershell_sha512='afca5d8553d612e36d04597de14cdba9731442d567d25fb9b0f1451116f299f773b4f49b5be7d4d89e3e874eb43f8c062ae70c2ed1d620244a2a52ba443cf4cb' \
&& echo "$powershell_sha512 PowerShell.Linux.Alpine.$powershell_version.nupkg" | sha512sum -c - \
&& mkdir -p /usr/share/powershell \
&& dotnet tool install --add-source / --tool-path /usr/share/powershell --version $powershell_version PowerShell.Linux.Alpine \
&& dotnet nuget locals all --clear \
&& rm PowerShell.Linux.Alpine.$powershell_version.nupkg \
&& chmod 755 /usr/share/powershell/pwsh \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
# To reduce image size, remove the copy nupkg that nuget keeps.
&& find /usr/share/powershell -print | grep -i '.*[.]nupkg$' | xargs rm \
# Add ncurses-terminfo-base to resolve psreadline dependency
&& apk add --no-cache ncurses-terminfo-base
Loading