Skip to content

Commit

Permalink
Use the current .NET 3.1, 5.0 and 6.0, to reduce the image size
Browse files Browse the repository at this point in the history
  • Loading branch information
thohng committed Mar 27, 2024
1 parent f4c5132 commit 5f4c584
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 51 deletions.
40 changes: 20 additions & 20 deletions docker-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,26 @@ $docker_compose_version = $docker_compose_version.Substring('Docker Compose vers
Write-Output "Docker compose version only: '$docker_compose_version'"
private:AddBuildArg 'DOCKER_COMPOSE_VERSION' $docker_compose_version

$dotnet_info_raw = $(docker run --rm mcr.microsoft.com/dotnet/sdk:3.1-focal dotnet --info) -join ' '
$dotnet_sdk_version = $dotnet_info_raw -replace '^.+\.NET Core SDKs installed:[^0-9]+([0-9.]+)[^0-9].*$', '$1'
$aspnetcore_version = $dotnet_info_raw -replace '^.+Microsoft.AspNetCore.App\s+([0-9.]+)[^0-9.].*$', '$1'
$dotnet_version = $dotnet_info_raw -replace '^.+Microsoft.NETCore.App\s+([0-9.]+)[^0-9.].*$', '$1'
Write-Output ".NETCore 3.1: Version SDK:$dotnet_sdk_version ASP.NET:$aspnetcore_version .NETCore:$dotnet_version"
private:AddBuildArg 'DOTNET_SDK_VERSION31' $dotnet_sdk_version
private:AddBuildArg 'ASPNET_VERSION31' $aspnetcore_version
private:AddBuildArg 'DOTNET_VERSION31' $dotnet_version

$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:5.0-focal sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION')
Write-Output ".NET 5.0: Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
private:AddBuildArg 'DOTNET_SDK_VERSION5' $dotnet_vers[0]
private:AddBuildArg 'ASPNET_VERSION5' $dotnet_vers[1]
private:AddBuildArg 'DOTNET_VERSION5' $dotnet_vers[2]

$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:6.0-focal sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION')
Write-Output ".NET 6.0: Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
private:AddBuildArg 'DOTNET_SDK_VERSION6' $dotnet_vers[0]
private:AddBuildArg 'ASPNET_VERSION6' $dotnet_vers[1]
private:AddBuildArg 'DOTNET_VERSION6' $dotnet_vers[2]
#$dotnet_info_raw = $(docker run --rm mcr.microsoft.com/dotnet/sdk:3.1-focal dotnet --info) -join ' '
#$dotnet_sdk_version = $dotnet_info_raw -replace '^.+\.NET Core SDKs installed:[^0-9]+([0-9.]+)[^0-9].*$', '$1'
#$aspnetcore_version = $dotnet_info_raw -replace '^.+Microsoft.AspNetCore.App\s+([0-9.]+)[^0-9.].*$', '$1'
#$dotnet_version = $dotnet_info_raw -replace '^.+Microsoft.NETCore.App\s+([0-9.]+)[^0-9.].*$', '$1'
#Write-Output ".NETCore 3.1: Version SDK:$dotnet_sdk_version ASP.NET:$aspnetcore_version .NETCore:$dotnet_version"
#private:AddBuildArg 'DOTNET_SDK_VERSION31' $dotnet_sdk_version
#private:AddBuildArg 'ASPNET_VERSION31' $aspnetcore_version
#private:AddBuildArg 'DOTNET_VERSION31' $dotnet_version

#$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:5.0-focal sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION')
#Write-Output ".NET 5.0: Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
#private:AddBuildArg 'DOTNET_SDK_VERSION5' $dotnet_vers[0]
#private:AddBuildArg 'ASPNET_VERSION5' $dotnet_vers[1]
#private:AddBuildArg 'DOTNET_VERSION5' $dotnet_vers[2]

#$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:6.0-focal sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION')
#Write-Output ".NET 6.0: Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
#private:AddBuildArg 'DOTNET_SDK_VERSION6' $dotnet_vers[0]
#private:AddBuildArg 'ASPNET_VERSION6' $dotnet_vers[1]
#private:AddBuildArg 'DOTNET_VERSION6' $dotnet_vers[2]

$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:7.0-jammy sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION')
Write-Output ".NET 7.0: Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
Expand Down
62 changes: 31 additions & 31 deletions teamcity-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG DOTNET_SDK_VERSION31_TAG=3.1-focal
ARG DOTNET_SDK_VERSION5_TAG=5.0-focal
ARG DOTNET_SDK_VERSION6_TAG=6.0-focal
#ARG DOTNET_SDK_VERSION31_TAG=3.1-focal
#ARG DOTNET_SDK_VERSION5_TAG=5.0-focal
#ARG DOTNET_SDK_VERSION6_TAG=6.0-focal
ARG DOTNET_SDK_VERSION7_TAG=7.0-jammy
ARG DOTNET_SDK_VERSION8_TAG=8.0-jammy
ARG DOTNET_SDK_VERSION9_TAG=9.0-preview-jammy
Expand All @@ -13,19 +13,19 @@ ARG TEAMCITYAGENT_IMAGE_TAG=2022.04.5-linux
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION9_TAG} AS dotnetsdk9
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION8_TAG} AS dotnetsdk8
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION7_TAG} AS dotnetsdk7
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION6_TAG} AS dotnetsdk6
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION5_TAG} AS dotnetsdk5
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION31_TAG} AS dotnetsdk3
#FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION6_TAG} AS dotnetsdk6
#FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION5_TAG} AS dotnetsdk5
#FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_SDK_VERSION31_TAG} AS dotnetsdk3
FROM $MINVER_IMAGE AS minver
FROM $DOCKER_CLI_IMAGE AS dockercli

FROM scratch AS build
# make sure folder exist
WORKDIR /usr/local/bin
WORKDIR /usr/share
COPY --from=dotnetsdk3 /usr/share/dotnet /usr/share/dotnet
COPY --from=dotnetsdk5 /usr/share/dotnet /usr/share/dotnet
COPY --from=dotnetsdk6 /usr/share/dotnet /usr/share/dotnet
#COPY --from=dotnetsdk3 /usr/share/dotnet /usr/share/dotnet
#COPY --from=dotnetsdk5 /usr/share/dotnet /usr/share/dotnet
#COPY --from=dotnetsdk6 /usr/share/dotnet /usr/share/dotnet
COPY --from=dotnetsdk7 /usr/share/dotnet /usr/share/dotnet
COPY --from=dotnetsdk8 /usr/share/dotnet /usr/share/dotnet
COPY --from=dotnetsdk9 /usr/share/dotnet /usr/share/dotnet
Expand All @@ -37,17 +37,17 @@ FROM ${TEAMCITYAGENT_IMAGE_REPOS}:${TEAMCITYAGENT_IMAGE_TAG} AS final

USER root

ARG DOTNET_SDK_VERSION31=3.1.0
ARG ASPNET_VERSION31=3.1.0
ARG DOTNET_VERSION31=3.1.0
#ARG DOTNET_SDK_VERSION31=3.1.0
#ARG ASPNET_VERSION31=3.1.0
#ARG DOTNET_VERSION31=3.1.0

ARG DOTNET_SDK_VERSION5=5.0.0
ARG ASPNET_VERSION5=5.0.0
ARG DOTNET_VERSION5=5.0.0
#ARG DOTNET_SDK_VERSION5=5.0.0
#ARG ASPNET_VERSION5=5.0.0
#ARG DOTNET_VERSION5=5.0.0

ARG DOTNET_SDK_VERSION6=6.0.0
ARG ASPNET_VERSION6=6.0.0
ARG DOTNET_VERSION6=6.0.0
#ARG DOTNET_SDK_VERSION6=6.0.0
#ARG ASPNET_VERSION6=6.0.0
#ARG DOTNET_VERSION6=6.0.0

ARG DOTNET_SDK_VERSION7=7.0.0
ARG ASPNET_VERSION7=7.0.0
Expand All @@ -66,19 +66,19 @@ ARG MINVER_VERSION=4.3.0
ARG DOCKER_COMPOSE_VERSION=2.24.6
# Install PowerShell global tool
# Install minver Console global tool
ENV DOTNET_SDK_VERSION31=${DOTNET_SDK_VERSION31} \
ASPNET_VERSION31=${ASPNET_VERSION31} \
DOTNET_VERSION31=${DOTNET_VERSION31} \
\
DOTNET_SDK_VERSION5=${DOTNET_SDK_VERSION5} \
ASPNET_VERSION5=${ASPNET_VERSION5} \
DOTNET_VERSION5=${DOTNET_VERSION5} \
\
DOTNET_SDK_VERSION6=${DOTNET_SDK_VERSION6} \
ASPNET_VERSION6=${ASPNET_VERSION6} \
DOTNET_VERSION6=${DOTNET_VERSION6} \
\
DOTNET_SDK_VERSION7=${DOTNET_SDK_VERSION7} \
#ENV DOTNET_SDK_VERSION31=${DOTNET_SDK_VERSION31} \
# ASPNET_VERSION31=${ASPNET_VERSION31} \
# DOTNET_VERSION31=${DOTNET_VERSION31} \
# \
# DOTNET_SDK_VERSION5=${DOTNET_SDK_VERSION5} \
# ASPNET_VERSION5=${ASPNET_VERSION5} \
# DOTNET_VERSION5=${DOTNET_VERSION5} \
# \
# DOTNET_SDK_VERSION6=${DOTNET_SDK_VERSION6} \
# ASPNET_VERSION6=${ASPNET_VERSION6} \
# DOTNET_VERSION6=${DOTNET_VERSION6} \
# \
ENV DOTNET_SDK_VERSION7=${DOTNET_SDK_VERSION7} \
ASPNET_VERSION7=${ASPNET_VERSION7} \
DOTNET_VERSION7=${DOTNET_VERSION7} \
\
Expand Down

0 comments on commit 5f4c584

Please sign in to comment.