Skip to content

Commit

Permalink
Support .NET 7.0 and 8.0, update GH Actions, cleanup #4
Browse files Browse the repository at this point in the history
  • Loading branch information
thohng authored Jul 15, 2023
2 parents 7b49546 + 22d8fff commit cea9702
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 124 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/docker-minver-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: build-${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Docker Repos Selection
id: repos
Expand All @@ -27,11 +27,11 @@ jobs:
$repos+='%0A'
$repos+='teslaconsulting/minver-cli'
}
Write-Output "::set-output name=content::$repos"
Write-Output "content=$repos" >> $env:GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v4
with:
images: |
${{ steps.repos.outputs.content }}
Expand All @@ -42,18 +42,18 @@ jobs:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ./minver
push: ${{ github.event_name != 'pull_request' }}
Expand Down
66 changes: 47 additions & 19 deletions .github/workflows/docker-teamcityagent-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: build-${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Docker Repos Selection
id: repos
Expand All @@ -27,11 +27,11 @@ jobs:
$repos+='%0A'
$repos+='teslaconsulting/teamcity-agent'
}
Write-Output "::set-output name=content::$repos"
Write-Output "content=$repos" >> $env:GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v4
with:
images: |
${{ steps.repos.outputs.content }}
Expand All @@ -46,11 +46,11 @@ jobs:
# uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
Expand All @@ -63,7 +63,7 @@ jobs:
Write-Output "Minver help:`n$minver_help"
$minver_version=$minver_help[0] -Replace '^[^0-9]+([0-9.]+)[^0-9].*$','$1'
Write-Output "Minver version: $minver_version"
Write-Output "::set-output name=version::$minver_version"
Write-Output "version=$minver_version" >> $env:GITHUB_OUTPUT
- name: Get Docker Compose version
id: docker_compose_version
Expand All @@ -72,7 +72,7 @@ jobs:
echo "Docker compose version raw: $DOCKER_COMPOSE_VERSION"
DOCKER_COMPOSE_VERSION=${DOCKER_COMPOSE_VERSION#Docker Compose version v}
echo "Docker compose version only: '$DOCKER_COMPOSE_VERSION'"
echo "::set-output name=version::$DOCKER_COMPOSE_VERSION"
echo "version=$DOCKER_COMPOSE_VERSION" >> $GITHUB_OUTPUT
- name: Get .NETCore 3.1 Versions
id: dotnetcore31_vers
Expand All @@ -83,33 +83,54 @@ jobs:
$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 "Version SDK:$dotnet_sdk_version ASP.NET:$aspnetcore_version .NETCore:$dotnet_version"
Write-Output "::set-output name=sdk::$dotnet_sdk_version"
Write-Output "::set-output name=aspnet::$aspnetcore_version"
Write-Output "::set-output name=dotnet::$dotnet_version"
Write-Output "sdk=$dotnet_sdk_version" >> $env:GITHUB_OUTPUT
Write-Output "aspnet=$aspnetcore_version" >> $env:GITHUB_OUTPUT
Write-Output "dotnet=$dotnet_version" >> $env:GITHUB_OUTPUT
- name: Get .NET 5 Versions
- name: Get .NET 5.0 Versions
id: dotnet5_vers
shell: pwsh
run: |
$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 "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
Write-Output "::set-output name=sdk::$($dotnet_vers[0])"
Write-Output "::set-output name=aspnet::$($dotnet_vers[1])"
Write-Output "::set-output name=dotnet::$($dotnet_vers[2])"
Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
Write-Output "dotnet=$($dotnet_vers[2])" >> $env:GITHUB_OUTPUT
- name: Get .NET 6 Versions
- name: Get .NET 6.0 Versions
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')
Write-Output "Version SDK:$($dotnet_vers[0]) ASP.NET:$($dotnet_vers[1]) .NETCore:$($dotnet_vers[2])"
Write-Output "::set-output name=sdk::$($dotnet_vers[0])"
Write-Output "::set-output name=aspnet::$($dotnet_vers[1])"
Write-Output "::set-output name=dotnet::$($dotnet_vers[2])"
Write-Output "sdk=$($dotnet_vers[0])" >> $env:GITHUB_OUTPUT
Write-Output "aspnet=$($dotnet_vers[1])" >> $env:GITHUB_OUTPUT
Write-Output "dotnet=$($dotnet_vers[2])" >> $env:GITHUB_OUTPUT
- name: Get .NET 7.0 Versions
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')
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
Write-Output "dotnet=$($dotnet_vers[2])" >> $env:GITHUB_OUTPUT
- name: Get .NET 8.0 Versions
id: dotnet8_vers
shell: pwsh
run: |
$dotnet_vers=$(docker run --rm mcr.microsoft.com/dotnet/sdk:8.0-preview-jammy 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
Write-Output "dotnet=$($dotnet_vers[2])" >> $env:GITHUB_OUTPUT
Write-Output "pwsh=$($dotnet_vers[3].SubString(11))" >> $env:GITHUB_OUTPUT
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ./teamcity-agent
push: ${{ github.event_name != 'pull_request' }}
Expand All @@ -127,5 +148,12 @@ jobs:
DOTNET_SDK_VERSION6=${{ steps.dotnet6_vers.outputs.sdk }}
ASPNET_VERSION6=${{ steps.dotnet6_vers.outputs.aspnet }}
DOTNET_VERSION6=${{ steps.dotnet6_vers.outputs.dotnet }}
DOTNET_SDK_VERSION7=${{ steps.dotnet7_vers.outputs.sdk }}
ASPNET_VERSION7=${{ steps.dotnet7_vers.outputs.aspnet }}
DOTNET_VERSION7=${{ steps.dotnet7_vers.outputs.dotnet }}
DOTNET_SDK_VERSION8=${{ steps.dotnet8_vers.outputs.sdk }}
ASPNET_VERSION8=${{ steps.dotnet8_vers.outputs.aspnet }}
DOTNET_VERSION8=${{ steps.dotnet8_vers.outputs.dotnet }}
POWERSHELL_VERSION=${{ steps.dotnet8_vers.outputs.pwsh }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Docker teamcity-agent with multi .NET SDKs

Customized Teamcity Agent image Ubuntu 20.04, add more tooks and .NET SDK
Customized Teamcity Agent image Ubuntu 20.04 (Focal Fossa), add more tooks and .NET SDK

## Docker Hub and Dockerfile

Expand All @@ -13,12 +13,11 @@ https://hub.docker.com/r/teslaconsulting/teamcity-agent
Update per build.

- Latest tag: `2022.04.4-linux`
- .NET 6 SDK: 6.0.401
- .NET 6 and ASP.NETCore 6: 6.0.9
- .NET 8 SDK: 8.0.100-preview.6.23330.14
- .NET 7 SDK: 7.0.306
- .NET 6 SDK: 6.0.412
- .NET 5 SDK: 5.0.408
- .NET 5 and ASP.NETCore 5: 5.0.17
- .NETCore 3.1 SDK: 3.1.423
- .NET 3.1 and ASP.NETCore 3.1: 3.1.29
- Powershell Core: 7.2.6
- MinVer Cli: 4.2.0
- Docker Compose v2: 2.11.2
- .NETCore 3.1 SDK: 3.1.426
- Powershell Core: 7.4.0-preview.3
- MinVer Cli: 4.3.0
- Docker Compose v2: 2.20.0
6 changes: 0 additions & 6 deletions compose/Dockerfile

This file was deleted.

7 changes: 4 additions & 3 deletions minver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0

# Install minver Console global tool
ARG DOTNET_MINVER_VERSION=4.2.0
ARG DOTNET_MINVER_SHA512=4a4588a6e22152549396364108b8657a6d0e4cb61937732f587286e3637950d993570dd592a210425fe4681e572369c214721cc035b3344105d381096e74ff29
ARG DOTNET_MINVER_VERSION=4.3.0
ARG DOTNET_MINVER_SHA512=90e851ccee7ec6249b0ba48221646a7d43b938fa074e3da7a22470ab0ea548d5c7e2a8b8628f3204d9ddf163f5c16f2b804d21f50165dc7e20848f155e288c0e
ENV DOTNET_MINVER_VERSION=${DOTNET_MINVER_VERSION}

RUN curl -SL --output minver-cli.$DOTNET_MINVER_VERSION.nupkg https://globalcdn.nuget.org/packages/minver-cli.$DOTNET_MINVER_VERSION.nupkg \
Expand All @@ -14,4 +14,5 @@ RUN curl -SL --output minver-cli.$DOTNET_MINVER_VERSION.nupkg https://globalcdn.
&& ln -s /usr/share/minver-cli/minver /usr/bin/minver \
&& chmod 755 /usr/share/minver-cli/minver \
&& find /usr/share/minver-cli -print | grep -i '.*[.]nupkg$' | xargs rm \
&& dotnet nuget locals all --clear
&& dotnet nuget locals all --clear \
&& minver --help
47 changes: 38 additions & 9 deletions teamcity-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
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-preview-jammy
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.4-linux

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 $MINVER_IMAGE AS minver
FROM $DOCKER_CLI_IMAGE AS dockercli
# FROM $DOCKER_CLI_IMAGE AS dockercli -> use apt-get install docker-compose-plugin

FROM scratch AS build
# make sure folder exist
Expand All @@ -20,9 +24,11 @@ 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=dotnetsdk6 /usr/share/powershell /usr/share/powershell
COPY --from=dotnetsdk7 /usr/share/dotnet /usr/share/dotnet
COPY --from=dotnetsdk8 /usr/share/dotnet /usr/share/dotnet
COPY --from=dotnetsdk8 /usr/share/powershell /usr/share/powershell
COPY --from=minver /usr/share/minver-cli /usr/share/minver-cli
COPY --from=dockercli /usr/libexec/docker/cli-plugins /usr/libexec/docker/cli-plugins
# COPY --from=dockercli /usr/local/libexec/docker/cli-plugins /usr/local/libexec/docker/cli-plugins

FROM ${TEAMCITYAGENT_IMAGE_REPOS}:${TEAMCITYAGENT_IMAGE_TAG} AS final

Expand All @@ -40,6 +46,14 @@ 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
ARG DOTNET_VERSION7=7.0.0

ARG DOTNET_SDK_VERSION8=8.0.0
ARG ASPNET_VERSION8=8.0.0
ARG DOTNET_VERSION8=8.0.0

ARG POWERSHELL_VERSION=7.2.6
ARG MINVER_VERSION=4.2.0
ARG DOCKER_COMPOSE_VERSION=2.11.2
Expand All @@ -57,9 +71,17 @@ ENV DOTNET_SDK_VERSION31=${DOTNET_SDK_VERSION31} \
ASPNET_VERSION6=${ASPNET_VERSION6} \
DOTNET_VERSION6=${DOTNET_VERSION6} \
\
DOTNET_SDK_VERSION=${DOTNET_SDK_VERSION6} \
ASPNET_VERSION=${ASPNET_VERSION6} \
DOTNET_VERSION=${DOTNET_VERSION6} \
DOTNET_SDK_VERSION7=${DOTNET_SDK_VERSION7} \
ASPNET_VERSION7=${ASPNET_VERSION7} \
DOTNET_VERSION7=${DOTNET_VERSION7} \
\
DOTNET_SDK_VERSION8=${DOTNET_SDK_VERSION8} \
ASPNET_VERSION8=${ASPNET_VERSION8} \
DOTNET_VERSION8=${DOTNET_VERSION8} \
\
DOTNET_SDK_VERSION=${DOTNET_SDK_VERSION8} \
ASPNET_VERSION=${ASPNET_VERSION8} \
DOTNET_VERSION=${DOTNET_VERSION8} \
\
POWERSHELL_VERSION=${POWERSHELL_VERSION} \
POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetSDK-Ubuntu-20.04 \
Expand All @@ -68,16 +90,23 @@ ENV DOTNET_SDK_VERSION31=${DOTNET_SDK_VERSION31} \

COPY --from=build /usr /usr

RUN ln -s /usr/share/powershell/pwsh /usr/bin/pwsh \
RUN apt-get update \
&& apt-get install docker-compose-plugin -y \
&& 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 \
&& [ -e /usr/local/bin/docker-compose ] && rm /usr/local/bin/docker-compose \
&& ln -s /usr/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 nuget locals all --clear
&& dotnet --help \
&& dotnet --info \
&& dotnet nuget locals all --clear \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

USER buildagent

Expand Down
Loading

0 comments on commit cea9702

Please sign in to comment.