Skip to content

Commit

Permalink
Refactor docker build and tag; temporary disable Ubuntu update to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
thohng committed Jun 7, 2024
1 parent 3f9a5e7 commit 9dc262f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 27 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/docker-teamcityagent-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
env:
IS_SEMVER_TAG: ${{ false }}
IS_TAG: ${{ null }}
DOTNET_SDK_VERSION6_TAG: 6.0-focal
DOTNET_SDK_VERSION7_TAG: 7.0-jammy
DOTNET_SDK_VERSION8_TAG: 8.0-jammy
DOTNET_SDK_VERSION9_TAG: 9.0-preview-noble
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -117,7 +121,7 @@ jobs:
id: dotnet6_vers
shell: pwsh
run: |
$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')
$dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:${{ env.DOTNET_SDK_VERSION6_TAG }} sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION')
Write-Output "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
Expand All @@ -127,7 +131,7 @@ jobs:
id: dotnet7_vers
shell: pwsh
run: |
$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')
$dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:${{ env.DOTNET_SDK_VERSION7_TAG }} sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION')
Write-Output "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
Expand All @@ -137,7 +141,7 @@ jobs:
id: dotnet8_vers
shell: pwsh
run: |
$dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:8.0-jammy sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION;pwsh --version')
$dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:${{ env.DOTNET_SDK_VERSION8_TAG }} sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION;pwsh --version')
Write-Output "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
Expand All @@ -148,7 +152,7 @@ jobs:
id: dotnet9_vers
shell: pwsh
run: |
$dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:9.0-preview-jammy sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION;pwsh --version')
$dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:${{ env.DOTNET_SDK_VERSION9_TAG }} sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION;pwsh --version')
Write-Output "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
Expand Down Expand Up @@ -179,6 +183,10 @@ jobs:
ASPNET_VERSION9=${{ steps.dotnet9_vers.outputs.aspnet }}
DOTNET_VERSION9=${{ steps.dotnet9_vers.outputs.dotnet }}
POWERSHELL_VERSION=${{ steps.dotnet9_vers.outputs.pwsh }}
DOTNET_SDK_VERSION6_TAG=${{ env.DOTNET_SDK_VERSION6_TAG }}
DOTNET_SDK_VERSION7_TAG=${{ env.DOTNET_SDK_VERSION7_TAG }}
DOTNET_SDK_VERSION8_TAG=${{ env.DOTNET_SDK_VERSION8_TAG }}
DOTNET_SDK_VERSION9_TAG=${{ env.DOTNET_SDK_VERSION9_TAG }}
unused: |
DOTNET_SDK_VERSION31=${{ steps.dotnetcore31_vers.outputs.sdk }}
ASPNET_VERSION31=${{ steps.dotnetcore31_vers.outputs.aspnet }}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ https://hub.docker.com/r/teslaconsulting/teamcity-agent

Update per build.

- TeamCity Agent: `2022.04.5-linux`
- .NET 9 SDK: 9.0.100-preview.2.24157.14
- .NET 8 SDK: 8.0.203
- .NET 7 SDK: 7.0.407
- .NET 6 SDK: 6.0.420
- TeamCity Agent: `2022.04.7-linux`
- .NET 9 SDK: 9.0.100-preview.4.24267.66
- .NET 8 SDK: 8.0.301
- .NET 7 SDK: 7.0.410
- .NET 6 SDK: 6.0.423
- .NET 5 SDK: 5.0.408
- .NETCore 3.1 SDK: 3.1.426
- Powershell Core: 7.5.0-preview.2
- MinVer Cli: 4.3.0
- Docker Compose v2: 2.26.0
- MinVer Cli: 5.0.0
- Docker Compose v2: 2.27.1
26 changes: 20 additions & 6 deletions docker-build.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)] [string] $Version = '2022.04.5-20240327-01',
[Parameter(Mandatory = $false)] [string] $SourceImageTag = '2022.04.5-linux',
[Parameter(Mandatory = $false)] [string] $Version, # = '2022.04.5-20240327-01',
[Parameter(Mandatory = $false)] [string] $SourceImageTag = '2022.04.7-linux',
[Parameter(Mandatory = $false)] [string[]] $DockerRepository = @('teslaconsulting/teamcity-agent'),
[Parameter(Mandatory = $false)] [string] $Branch,
[Parameter(Mandatory = $false)] [string] $Sha,
[Parameter(Mandatory = $false)] [string] $DotnetSdkVersion6Tag = '6.0-focal',
[Parameter(Mandatory = $false)] [string] $DotnetSdkVersion7Tag = '7.0-jammy',
[Parameter(Mandatory = $false)] [string] $DotnetSdkVersion8Tag = '8.0-jammy',
[Parameter(Mandatory = $false)] [string] $DotnetSdkVersion9Tag = '9.0-preview-noble',
[Parameter(Mandatory = $false)] [switch] $NoSquash,
[Parameter(Mandatory = $false)] [switch] $Latest,
[Parameter(Mandatory = $false)] [switch] $WhatIf
Expand Down Expand Up @@ -43,6 +47,11 @@ $root = Split-Path $MyInvocation.MyCommand.Path -Parent -Resolve
$imageTags = @()
private:AddImageTag "sha-$($Sha)"
private:AddImageTag $Branch
if (!$Version) {
$Version = ($SourceImageTag.EndsWith('-linux') ? $SourceImageTag.Substring(0, $SourceImageTag.Length - 5) : $SourceImageTag) + (Get-Date).ToString('yyyyMMdd-HHmmss')
}
#Write-Host "Version: $Version"

AddTag '^(\d+)\.\d+(\.\d+)?(-.+)?$'
AddTag '^(\d+\.\d+)(\.\d+)?(-.+)?$'
AddTag '^(\d+\.\d+(\.\d+)?)(-.+)?$'
Expand Down Expand Up @@ -101,31 +110,36 @@ private:AddBuildArg 'DOCKER_COMPOSE_VERSION' $docker_compose_version
#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')
$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:$DotnetSdkVersion6Tag 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')
$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:$DotnetSdkVersion7Tag 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])"
private:AddBuildArg 'DOTNET_SDK_VERSION7' $dotnet_vers[0]
private:AddBuildArg 'ASPNET_VERSION7' $dotnet_vers[1]
private:AddBuildArg 'DOTNET_VERSION7' $dotnet_vers[2]

$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:8.0-jammy sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION;pwsh --version')
$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:$DotnetSdkVersion8Tag sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION;pwsh --version')
Write-Output ".NET 8.0: Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2]) PowerShell:$($dotnet_vers[3].SubString(11))"
private:AddBuildArg 'DOTNET_SDK_VERSION8' $dotnet_vers[0]
private:AddBuildArg 'ASPNET_VERSION8' $dotnet_vers[1]
private:AddBuildArg 'DOTNET_VERSION8' $dotnet_vers[2]

$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:9.0-preview-jammy sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION;pwsh --version')
$dotnet_vers = $(docker run --rm mcr.microsoft.com/dotnet/sdk:$DotnetSdkVersion9Tag sh -c 'echo $DOTNET_SDK_VERSION;echo $ASPNET_VERSION;echo $DOTNET_VERSION;pwsh --version')
Write-Output ".NET 9.0: Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2]) PowerShell:$($dotnet_vers[3].SubString(11))"
private:AddBuildArg 'DOTNET_SDK_VERSION9' $dotnet_vers[0]
private:AddBuildArg 'ASPNET_VERSION9' $dotnet_vers[1]
private:AddBuildArg 'DOTNET_VERSION9' $dotnet_vers[2]
private:AddBuildArg 'POWERSHELL_VERSION' $dotnet_vers[3].SubString(11)
private:AddBuildArg 'POWERSHELL_DISTRIBUTION_CHANNEL' 'PSDocker-DotnetSDK-Ubuntu-20.04'

private:AddBuildArg 'DOTNET_SDK_VERSION6_TAG' $DotnetSdkVersion6Tag
private:AddBuildArg 'DOTNET_SDK_VERSION7_TAG' $DotnetSdkVersion7Tag
private:AddBuildArg 'DOTNET_SDK_VERSION8_TAG' $DotnetSdkVersion8Tag
private:AddBuildArg 'DOTNET_SDK_VERSION9_TAG' $DotnetSdkVersion9Tag
#===========================================================

Write-Verbose "Execute: docker $params"
Expand Down
33 changes: 23 additions & 10 deletions teamcity-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
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
ARG DOTNET_SDK_VERSION9_TAG=9.0-preview-noble
ARG MINVER_IMAGE_TAG=latest
ARG MINVER_IMAGE=teslaconsulting/minver-cli:$MINVER_IMAGE_TAG
ARG DOCKER_CLI_IMAGE=docker:cli
ARG TEAMCITYAGENT_IMAGE_REPOS=jetbrains/teamcity-agent
ARG TEAMCITYAGENT_IMAGE_TAG=2022.04.5-linux
ARG TEAMCITYAGENT_IMAGE_TAG=2022.04.7-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
Expand Down Expand Up @@ -101,11 +101,26 @@ ENV DOTNET_SDK_VERSION6=${DOTNET_SDK_VERSION6} \

COPY --from=build /usr /usr

RUN curl -s https://package.perforce.com/perforce.pubkey | gpg --dearmor | tee /usr/share/keyrings/perforce.gpg \
&& echo 'deb [signed-by=/usr/share/keyrings/perforce.gpg] https://package.perforce.com/apt/ubuntu focal release' > /etc/apt/sources.list.d/perforce.list \
&& apt-get update \
&& apt-get upgrade -y \
&& ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
# RUN curl -s https://package.perforce.com/perforce.pubkey | gpg --dearmor | tee /usr/share/keyrings/perforce.gpg \
# && echo 'deb [signed-by=/usr/share/keyrings/perforce.gpg] https://package.perforce.com/apt/ubuntu focal release' > /etc/apt/sources.list.d/perforce.list \
# && apt-get update \
# && apt-get upgrade -y \
# && ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
# && chmod 755 /usr/share/powershell/pwsh \
# && ln -s /usr/share/minver-cli/minver /usr/bin/minver \
# && chmod +x /usr/share/minver-cli/minver \
# && rm /usr/local/bin/docker-compose \
# && ln -s /usr/local/libexec/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose \
# && chmod +x /usr/libexec/docker/cli-plugins/docker-* \
# # Install module Pester - for root user
# && pwsh -Command "Install-Module -Name Pester -Scope AllUsers -Force" \
# && dotnet --help \
# && dotnet --info \
# && dotnet nuget locals all --clear \
# && apt-get clean \
# && rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

RUN ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
&& chmod 755 /usr/share/powershell/pwsh \
&& ln -s /usr/share/minver-cli/minver /usr/bin/minver \
&& chmod +x /usr/share/minver-cli/minver \
Expand All @@ -116,9 +131,7 @@ RUN curl -s https://package.perforce.com/perforce.pubkey | gpg --dearmor | tee
&& pwsh -Command "Install-Module -Name Pester -Scope AllUsers -Force" \
&& dotnet --help \
&& dotnet --info \
&& dotnet nuget locals all --clear \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
&& dotnet nuget locals all --clear

USER buildagent

Expand Down

0 comments on commit 9dc262f

Please sign in to comment.