Created
October 27, 2021 09:36
-
-
Save gistlyn/dfedc2e0c3195c99a7694ef14eec5e86 to your computer and use it in GitHub Desktop.
Create Linux TeamCity Agent with .NET 6.0 RC2
This file contains hidden or 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
FROM jetbrains/teamcity-agent:latest | |
ARG DEBIAN_FRONTEND=noninteractive | |
USER root | |
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils | |
RUN apt-get update | |
# remove previous dotnet from teamcity-agent install | |
RUN rm /usr/bin/dotnet \ | |
&& rm -rf /usr/share/dotnet \ | |
&& mkdir -p /usr/share/dotnet/shared | |
# (runtime) from https://github.com/dotnet/dotnet-docker/blob/main/src/runtime/6.0/bullseye-slim/amd64/Dockerfile | |
RUN curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.0-rc.2.21480.5/dotnet-runtime-6.0.0-rc.2.21480.5-linux-x64.tar.gz \ | |
&& dotnet_sha512='45062417c6111af4d635868927e8f69d43f66c9e0f111cb71c1861eaf5ceda4aefa99d97c6ce3b13fac2bc7c57c435e6f8b2d43c51a3bb3304b42081d98f7047' \ | |
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \ | |
&& mkdir -p /dotnet \ | |
&& tar -ozxf dotnet.tar.gz -C /usr/share/dotnet \ | |
&& rm dotnet.tar.gz | |
ENV DOTNET_VERSION=6.0.0-rc.2.21480.3 | |
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet | |
# (aspnetcore) from https://github.com/dotnet/dotnet-docker/blob/main/src/aspnet/6.0/bullseye-slim/amd64/Dockerfile | |
# Retrieve ASP.NET Core | |
RUN curl -SL --output aspnetcore.tar.gz https://dotnetcli.azureedge.net/dotnet/aspnetcore/Runtime/6.0.0-rc.2.21480.10/aspnetcore-runtime-6.0.0-rc.2.21480.10-linux-x64.tar.gz \ | |
&& aspnetcore_sha512='d48895237644a3999663b2e16baa2303d8b77f66385a04d8edb5601fdffacce18b1b1318827d09f74f6b133ff2c179ef659bd21cf8460289b5f81f404fa8b326' \ | |
&& echo "$aspnetcore_sha512 aspnetcore.tar.gz" | sha512sum -c - \ | |
&& tar -ozxf aspnetcore.tar.gz ./shared/Microsoft.AspNetCore.App -C /usr/share/dotnet/shared/Microsoft.AspNetCore.App \ | |
&& rm aspnetcore.tar.gz | |
# (sdk) from https://github.com/dotnet/dotnet-docker/blob/main/src/sdk/6.0/focal/amd64/Dockerfile | |
ENV \ | |
# Unset ASPNETCORE_URLS from aspnet base image | |
ASPNETCORE_URLS= \ | |
# Do not generate certificate | |
DOTNET_GENERATE_ASPNET_CERTIFICATE=false \ | |
# Do not show first run text | |
DOTNET_NOLOGO=true \ | |
# SDK version | |
DOTNET_SDK_VERSION=6.0.100-rc.2.21505.57 \ | |
#DOTNET_SDK_VERSION=6.0.0-rc.2.21480.5 \ | |
# Enable correct mode for dotnet watch (only mode supported in a container) | |
DOTNET_USE_POLLING_FILE_WATCHER=true \ | |
# Unset Logging__Console__FormatterName from aspnet base image | |
Logging__Console__FormatterName= \ | |
# 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-DotnetSDK-Ubuntu-20.04 | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends \ | |
curl \ | |
git \ | |
wget \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install .NET SDK | |
RUN curl -SL --output dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \ | |
&& dotnet_sha512='0a8f85a2757f61ca7f9b8c546af4554c2aac9cdb06f6d62879a60de6f2a3d37ea7136f48896c9c85828a2d55df354e7b9b5b4dc22896c927f0c6370a5ade1b9c' \ | |
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \ | |
&& mkdir -p /usr/share/dotnet \ | |
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz ./packs ./sdk ./sdk-manifests ./templates ./LICENSE.txt ./ThirdPartyNotices.txt \ | |
&& rm dotnet.tar.gz \ | |
# Trigger first run experience by running arbitrary cmd | |
&& dotnet help | |
# Install PowerShell global tool | |
RUN powershell_version=7.2.0-preview.10 \ | |
&& curl -SL --output PowerShell.Linux.x64.$powershell_version.nupkg https://pwshtool.blob.core.windows.net/tool/$powershell_version/PowerShell.Linux.x64.$powershell_version.nupkg \ | |
&& powershell_sha512='bcf4cb050215742e08a31079b85b9289955017c91a6c6c5bb2865b0ff5c9a967422c9c5235b0e38329d2d44fd2d1c40922f55371df782ed7e44fdf048c229a0a' \ | |
&& echo "$powershell_sha512 PowerShell.Linux.x64.$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.x64 \ | |
&& dotnet nuget locals all --clear \ | |
&& rm PowerShell.Linux.x64.$powershell_version.nupkg \ | |
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \ | |
&& chmod 755 /usr/share/powershell/pwsh \ | |
# To reduce image size, remove the copy nupkg that nuget keeps. | |
&& find /usr/share/powershell -print | grep -i '.*[.]nupkg$' | xargs rm | |
ENV TEAMCITY_AGENT_HOME=/opt/buildAgent/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment