From 31a0adec8dd1b3fb404f26cbf629da50c88218fa Mon Sep 17 00:00:00 2001 From: Mark Harrison Date: Tue, 26 Sep 2023 11:54:37 +0100 Subject: [PATCH 1/2] Add Windows 2022 support --- .github/workflows/docker-build-push.yml | 103 +++++++++++++++--- ...tFlywayVersion.ps1 => GetFlywayVersion.ps1 | 0 README.md | 17 ++- windows-2022/Dockerfile | 23 ++++ 4 files changed, 122 insertions(+), 21 deletions(-) rename windows-2019/GetFlywayVersion.ps1 => GetFlywayVersion.ps1 (100%) create mode 100644 windows-2022/Dockerfile diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 9511e3a..f9d4563 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -14,6 +14,8 @@ jobs: outputs: FLYWAY_VERSION: ${{ steps.step1.outputs.CURRENT_FLYWAY_VERSION }} CONTINUE: ${{ steps.step1.outputs.Continue }} + WIN2019_VERSION: ${{ steps.step1.outputs.WIN2019_VERSION }} + WIN2022_VERSION: ${{ steps.step1.outputs.WIN2022_VERSION }} steps: - uses: actions/checkout@v3 - id: step1 @@ -38,7 +40,23 @@ jobs: { Write-Host "We need to upgrade the flyway container to $latestFlywayVersion" echo "CONTINUE=Yes" >> $env:GITHUB_OUTPUT - } + } + + Write-Host "Getting OS versions for windows 2022 and 2019" + $win2019_manifest = (docker manifest inspect --verbose "octopuslabs/workertools:latest-windows.2019" | ConvertFrom-Json) + $WIN2019_VERSION = $win2019_manifest.Descriptor.Platform.'os.version' + Write-Host "WIN2019_VERSION: $WIN2019_VERSION" + + $win2022_manifest = (docker manifest inspect --verbose "octopuslabs/workertools:latest-windows.2022" | ConvertFrom-Json) + $WIN2022_VERSION = $win2022_manifest.Descriptor.Platform.'os.version' + Write-Host "WIN2022_VERSION: $WIN2022_VERSION" + + if([string]::IsNullOrWhiteSpace($WIN2019_VERSION) -or [string]::IsNullOrWhiteSpace($WIN2022_VERSION)) { + throw "Could not establish OS versions for windows 2022 and 2019 needed for docker manifest" + } + + echo "WIN2019_VERSION=$WIN2019_VERSION" >> $env:GITHUB_OUTPUT + echo "WIN2022_VERSION=$WIN2022_VERSION" >> $env:GITHUB_OUTPUT shell: powershell build-ubuntu: @@ -55,35 +73,35 @@ jobs: run: docker login --username $USERNAME --password "$PASSWORD" if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Build the ubuntu-20.04 Docker image + - name: Build the ubuntu.2004 image env: FLYWAY_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.FLYWAY_VERSION }} run: docker build ./ubuntu-2004 --tag octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD-ubuntu.2004 --tag octopuslabs/flyway-workertools:latest-ubuntu.2004 --build-arg FLYWAY_VERSION=$FLYWAY_VERSION_TO_BUILD if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Push the ubuntu-20.04 version image + - name: Push the ubuntu.2004 version-specific image env: FLYWAY_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.FLYWAY_VERSION }} run: docker push octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD-ubuntu.2004 if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Push the latest ubuntu-20.04 image + - name: Push the ubuntu.2004 latest image run: docker push octopuslabs/flyway-workertools:latest-ubuntu.2004 if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - - name: Build the ubuntu-22.04 Docker image + + - name: Build the ubuntu.2204 image env: FLYWAY_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.FLYWAY_VERSION }} run: docker build ./ubuntu-2204 --tag octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD-ubuntu.2204 --tag octopuslabs/flyway-workertools:latest-ubuntu.2204 --build-arg FLYWAY_VERSION=$FLYWAY_VERSION_TO_BUILD if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Push the ubuntu-22.04 version image + - name: Push the ubuntu.2204 version-specific image env: FLYWAY_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.FLYWAY_VERSION }} run: docker push octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD-ubuntu.2204 if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Push the latest ubuntu-22.04 image + - name: Push the ubuntu.2204 latest image run: docker push octopuslabs/flyway-workertools:latest-ubuntu.2204 if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} @@ -101,24 +119,54 @@ jobs: run: docker login --username ${env:USERNAME} --password "${env:PASSWORD}" if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Build the win2019 Docker image + - name: Build the win2019 image env: FLYWAY_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.FLYWAY_VERSION }} run: docker build ./windows-2019 --tag octopuslabs/flyway-workertools:${env:FLYWAY_VERSION_TO_BUILD}-windows.2019 --tag octopuslabs/flyway-workertools:latest-windows.2019 --build-arg FLYWAY_VERSION=${env:FLYWAY_VERSION_TO_BUILD} if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Push the win2019 version image + - name: Push the win2019 version-specific image env: FLYWAY_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.FLYWAY_VERSION }} run: docker push octopuslabs/flyway-workertools:${env:FLYWAY_VERSION_TO_BUILD}-windows.2019 if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Push the latest win2019 image + - name: Push the win2019 latest image run: docker push octopuslabs/flyway-workertools:latest-windows.2019 if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} + + build-win-2022: + needs: [get-version-number] + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v3 + + - name: DockerHub Login + env: + USERNAME: ${{ secrets.DOCKER_HUB_USER }} + PASSWORD: ${{ secrets.DOCKER_HUB_PAT }} + run: docker login --username ${env:USERNAME} --password "${env:PASSWORD}" + if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} + + - name: Build the win2022 image + env: + FLYWAY_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.FLYWAY_VERSION }} + run: docker build ./windows-2022 --tag octopuslabs/flyway-workertools:${env:FLYWAY_VERSION_TO_BUILD}-windows.2022 --tag octopuslabs/flyway-workertools:latest-windows.2022 --build-arg FLYWAY_VERSION=${env:FLYWAY_VERSION_TO_BUILD} + if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} + + - name: Push the win2022 version-specific image + env: + FLYWAY_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.FLYWAY_VERSION }} + run: docker push octopuslabs/flyway-workertools:${env:FLYWAY_VERSION_TO_BUILD}-windows.2022 + if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} + + - name: Push the win2022 latest image + run: docker push octopuslabs/flyway-workertools:latest-windows.2022 + if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} build-docker-manifest: - needs: [get-version-number, build-ubuntu, build-win-2019] + needs: [get-version-number, build-ubuntu, build-win-2019, build-win-2022] runs-on: ubuntu-latest steps: @@ -129,21 +177,40 @@ jobs: run: docker login --username $USERNAME --password "$PASSWORD" if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Build Manifest - run: docker manifest create octopuslabs/flyway-workertools:latest octopuslabs/flyway-workertools:latest-windows.2019 octopuslabs/flyway-workertools:latest-ubuntu.2004 + - name: Create docker manifest for latest tag + run: docker manifest create octopuslabs/flyway-workertools:latest octopuslabs/flyway-workertools:latest-windows.2019 octopuslabs/flyway-workertools:latest-ubuntu.2204 + if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} + + - name: Annotate docker manifest for latest tag + env: + WIN2019_VERSION: ${{ needs.get-version-number.outputs.WIN2019_VERSION }} + WIN2022_VERSION: ${{ needs.get-version-number.outputs.WIN2022_VERSION }} + run: | + docker manifest annotate --os "windows" --os-version "$WIN2019_VERSION" --arch "amd64" "octopuslabs/flyway-workertools:latest" "octopuslabs/flyway-workertools:latest-windows.2019" && \ + docker manifest annotate --os "windows" --os-version "$WIN2022_VERSION" --arch "amd64" "octopuslabs/flyway-workertools:latest" "octopuslabs/flyway-workertools:latest-windows.2022" if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Push Manifest + - name: Push docker manifest for latest tag run: docker manifest push octopuslabs/flyway-workertools:latest if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Build Version Manifest + - name: Create docker manifest for version-specific tag env: FLYWAY_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.FLYWAY_VERSION }} - run: docker manifest create octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD-windows.2019 octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD-ubuntu.2004 + run: docker manifest create octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD-windows.2019 octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD-windows.2022 octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD-ubuntu.2204 + if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} + + - name: Annotate docker manifest for version-specific tag + env: + VERSION_NUMBER: ${{ needs.get-version-number.outputs.VERSION }} + WIN2019_VERSION: ${{ needs.get-version-number.outputs.WIN2019_VERSION }} + WIN2022_VERSION: ${{ needs.get-version-number.outputs.WIN2022_VERSION }} + run: | + docker manifest annotate --os "windows" --os-version "$WIN2019_VERSION" --arch "amd64" "octopuslabs/flyway-workertools:$VERSION_NUMBER" "octopuslabs/flyway-workertools:$VERSION_NUMBER-windows.2019" && \ + docker manifest annotate --os "windows" --os-version "$WIN2022_VERSION" --arch "amd64" "octopuslabs/flyway-workertools:$VERSION_NUMBER" "octopuslabs/flyway-workertools:$VERSION_NUMBER-windows.2022" if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - - name: Push Version Manifest + - name: Push docker manifest for version-specific tag env: FLYWAY_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.FLYWAY_VERSION }} run: docker manifest push octopuslabs/flyway-workertools:$FLYWAY_VERSION_TO_BUILD diff --git a/windows-2019/GetFlywayVersion.ps1 b/GetFlywayVersion.ps1 similarity index 100% rename from windows-2019/GetFlywayVersion.ps1 rename to GetFlywayVersion.ps1 diff --git a/README.md b/README.md index 8000cde..53a7b5c 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,20 @@ This repository contains images that contain the tooling necessary to to use the The following images are built in this repo: - Ubuntu 22.04 -- Ubuntu 20.04 (tagged `latest` in [DockerHub](https://hub.docker.com/r/octopuslabs/flyway-workertools/tags?page=1&name=latest)) -- Windows 2019 (tagged `latest` in [DockerHub](https://hub.docker.com/r/octopuslabs/flyway-workertools/tags?page=1&name=latest)) +- Ubuntu 20.04 +- Windows 2022 +- Windows 2019 A new image will be built each time a new version of flyway is created. The version numbers will be based on the version of the Flyway tool. -**Please consider this repository provided as is. If there are any issues please do not contact support.** +## Deprecated tags + +Over time, certain tags will be deprecated, usually according to their mainstream support end date. New versions for any matching images will stop being maintained and pushed based on the end date shown. + +Tag | End date +---------| --------------- +`windows.2019`| [Jan 9th, 2024](https://learn.microsoft.com/en-us/lifecycle/products/windows-server-2019) + +## Support + +Please consider this repository provided as is. If there are any issues please do not contact support. diff --git a/windows-2022/Dockerfile b/windows-2022/Dockerfile new file mode 100644 index 0000000..aa338df --- /dev/null +++ b/windows-2022/Dockerfile @@ -0,0 +1,23 @@ +# escape=` + +FROM octopuslabs/workertools:latest-windows.2022 +SHELL ["powershell", "-Command"] + +ARG FLYWAY_VERSION=7.7.1 + +# Get SQL Fluff for Flyway Check Command +RUN pip3 install sqlfluff==1.2.1 + +# # Install Flyway +RUN Invoke-WebRequest "https://download.red-gate.com/maven/release/org/flywaydb/enterprise/flyway-commandline/${env:FLYWAY_VERSION}/flyway-commandline-${env:FLYWAY_VERSION}-windows-x64.zip" -OutFile flyway-cli.zip; ` + & '.\Program Files\7-Zip\7z.exe' x .\flyway-cli.zip; ` + rm .\flyway-cli.zip; + +RUN $old = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path).path; ` + Write-Host $old; ` + $flywayPath = ';C:\flyway-' + ${env:FLYWAY_VERSION}; ` + $new = $old + $flywayPath; ` + Write-Host $new; ` + Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path -Value $new; ` + Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1; ` + refreshenv \ No newline at end of file From d5f05c58c49b7107278c87c853addbbaa28e0d93 Mon Sep 17 00:00:00 2001 From: Mark Harrison Date: Tue, 26 Sep 2023 12:16:16 +0100 Subject: [PATCH 2/2] Fix latest manifest --- .github/workflows/docker-build-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index f9d4563..8116ca9 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -178,7 +178,7 @@ jobs: if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - name: Create docker manifest for latest tag - run: docker manifest create octopuslabs/flyway-workertools:latest octopuslabs/flyway-workertools:latest-windows.2019 octopuslabs/flyway-workertools:latest-ubuntu.2204 + run: docker manifest create octopuslabs/flyway-workertools:latest octopuslabs/flyway-workertools:latest-windows.2019 octopuslabs/flyway-workertools:latest-windows.2022 octopuslabs/flyway-workertools:latest-ubuntu.2204 if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} - name: Annotate docker manifest for latest tag