From 59e08f6b8bcfea4ab1ed19ce58cedde9e40446f3 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Thu, 29 Feb 2024 08:54:37 +0100 Subject: [PATCH] chore: build multiple windows images Signed-off-by: Dominik Rosiek --- .github/workflows/dev_builds.yml | 12 +++++++---- .github/workflows/pull_requests.yml | 4 +++- Dockerfile_windows | 3 ++- Makefile | 12 +++++++++-- ci/build-push-multiplatform.sh | 26 ++++++++++++++++++++++-- ci/push_docker_multiplatform_manifest.sh | 11 ++++++++-- 6 files changed, 56 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml index 51628892c1..3e5ab007bc 100644 --- a/.github/workflows/dev_builds.yml +++ b/.github/workflows/dev_builds.yml @@ -227,12 +227,16 @@ jobs: name: otelcol-sumo-${{matrix.arch_os}}.exe path: artifacts/ - - name: Build and push image to Open Source ECR + - name: Build and push images to Open Source ECR run: | cp artifacts/otelcol-sumo-${{matrix.arch_os}}.exe otelcol-sumo.exe make build-push-container-windows-dev \ BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \ - PLATFORM=${{ matrix.arch_os }} + PLATFORM=${{ matrix.arch_os }}_ltsc2022 + + make build-push-container-windows-dev \ + BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \ + PLATFORM=${{ matrix.arch_os }}_ltsc2019 push-docker-manifest: name: Push joint container manifest @@ -278,13 +282,13 @@ jobs: make push-container-manifest-dev \ BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \ PLATFORMS="linux/amd64" \ - BUILD_TYPE_SUFFIX="-ubi-fips" + BUILD_TYPE_SUFFIX="-ubi-fips"s - name: Push joint container manifest for all platforms to Open Source ECR run: | make push-container-manifest-dev \ BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \ - PLATFORMS="linux/amd64 linux/arm64 windows/amd64" + PLATFORMS="linux/amd64 linux/arm64 windows/amd64/ltsc2022 windows/amd64/ltsc2019" - name: Push joint UBI-based container manifest for all platforms to Open Source ECR run: | diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 849c571ed1..b37ee5902a 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -397,7 +397,9 @@ jobs: run: | cp artifacts/otelcol-sumo-${{matrix.arch_os}}.exe otelcol-sumo.exe make build-container-windows \ - PLATFORM=${{ matrix.arch_os }} + PLATFORM=${{ matrix.arch_os }}_ltsc2022 + make build-container-windows \ + PLATFORM=${{ matrix.arch_os }}_ltsc2019 - name: Test built image if: steps.changed-files.outputs.any_changed == 'true' diff --git a/Dockerfile_windows b/Dockerfile_windows index 14ada642d9..77f8dba592 100644 --- a/Dockerfile_windows +++ b/Dockerfile_windows @@ -1,4 +1,5 @@ -FROM mcr.microsoft.com/windows/servercore:ltsc2022 +ARG BASE_VERSION=ltsc2022 +FROM mcr.microsoft.com/windows/servercore:${BASE_VERSION} ARG BUILD_TAG=latest ENV TAG $BUILD_TAG diff --git a/Makefile b/Makefile index d5e8dc0313..8b3ca10264 100644 --- a/Makefile +++ b/Makefile @@ -243,6 +243,7 @@ OPENSOURCE_ECR_URL = public.ecr.aws/sumologic OPENSOURCE_REPO_URL = $(OPENSOURCE_ECR_URL)/$(IMAGE_NAME) OPENSOURCE_REPO_URL_DEV = $(OPENSOURCE_ECR_URL)/$(IMAGE_NAME_DEV) REPO_URL = $(OPENSOURCE_REPO_URL) +BASE_VERSION ?= "" DOCKERFILE = Dockerfile @@ -302,14 +303,21 @@ _build-container-multiplatform: REPO_URL="$(REPO_URL)" \ DOCKERFILE="$(DOCKERFILE)" \ PLATFORM="$(PLATFORM)" \ + BASE_VERSION="${BASE_VERSION}" \ ./ci/build-push-multiplatform.sh $(PUSH) .PHONY: build-container-multiplatform build-container-multiplatform: _build-container-multiplatform .PHONY: build-container-windows -build-container-windows: DOCKERFILE = Dockerfile_windows -build-container-windows: _build-container-multiplatform +build-container-windows: + $(MAKE) _build-container-multiplatform \ + DOCKERFILE=Dockerfile_windows \ + BASE_VERSION=ltsc2022 + + $(MAKE) _build-container-multiplatform \ + DOCKERFILE=Dockerfile_windows \ + BASE_VERSION=ltsc2019 .PHONY: build-push-container-windows build-push-container-windows: PUSH = --push diff --git a/ci/build-push-multiplatform.sh b/ci/build-push-multiplatform.sh index 1d7c1d2b0d..5c5bfcea11 100755 --- a/ci/build-push-multiplatform.sh +++ b/ci/build-push-multiplatform.sh @@ -40,6 +40,10 @@ if [[ -z "${REPO_URL}" ]]; then exit 1 fi +if [[ ! -z "${BASE_VERSION}" ]]; then + BASE_VERSION="-${BASE_VERSION}" +fi + if [[ -z "${PLATFORM}" ]]; then echo "No PLATFORM passed in" exit 1 @@ -80,6 +84,20 @@ function build_push() { PLATFORM="windows/amd64" ;; + "windows/amd64/ltsc2022"|"windows_amd64_ltsc2022") + readonly BUILD_ARCH="amd64" + readonly BUILD_PLATFORM="windows" + readonly BASE_VERSION="-ltsc2022" + PLATFORM="windows/amd64" + ;; + + "windows/amd64/ltsc2019"|"windows_amd64_ltsc2019") + readonly BUILD_ARCH="amd64" + readonly BUILD_PLATFORM="windows" + readonly BASE_VERSION="-ltsc2019" + PLATFORM="windows/amd64" + ;; + # Can't really enable it for now because: # !shopify/sarama@v1.29.0/gssapi_kerberos.go:62:10: constant 4294967295 overflows int # ref: https://github.com/SumoLogic/sumologic-otel-collector/runs/2805247906 @@ -97,9 +115,9 @@ function build_push() { esac local TAG - readonly TAG="${REPO_URL}:${BUILD_TAG}${BUILD_TYPE_SUFFIX}-${BUILD_PLATFORM}-${BUILD_ARCH}" + readonly TAG="${REPO_URL}:${BUILD_TAG}${BUILD_TYPE_SUFFIX}-${BUILD_PLATFORM}-${BUILD_ARCH}${BASE_VERSION}" local LATEST_TAG - readonly LATEST_TAG="${REPO_URL}:latest${BUILD_TYPE_SUFFIX}-${BUILD_PLATFORM}-${BUILD_ARCH}" + readonly LATEST_TAG="${REPO_URL}:latest${BUILD_TYPE_SUFFIX}-${BUILD_PLATFORM}-${BUILD_ARCH}${BASE_VERSION}" # --provenance=false for docker buildx ensures that we create manifest instead of manifest list if [[ "${PUSH}" == true ]]; then @@ -109,6 +127,7 @@ function build_push() { docker build \ --file "${DOCKERFILE}" \ --build-arg BUILD_TAG="${BUILD_TAG}" \ + --build-arg BASE_VERSION="${BASE_VERSION}" \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --platform="${PLATFORM}" \ --tag "${LATEST_TAG}" \ @@ -123,6 +142,7 @@ function build_push() { --push \ --file "${DOCKERFILE}" \ --build-arg BUILD_TAG="${BUILD_TAG}" \ + --build-arg BASE_VERSION="${BASE_VERSION}" \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --platform="${PLATFORM}" \ --tag "${LATEST_TAG}" \ @@ -136,6 +156,7 @@ function build_push() { docker build \ --file "${DOCKERFILE}" \ --build-arg BUILD_TAG="latest${BUILD_TYPE_SUFFIX}" \ + --build-arg BASE_VERSION="${BASE_VERSION}" \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --platform="${PLATFORM}" \ --tag "${REPO_URL}:latest${BUILD_TYPE_SUFFIX}" \ @@ -146,6 +167,7 @@ function build_push() { docker buildx build \ --file "${DOCKERFILE}" \ --build-arg BUILD_TAG="latest${BUILD_TYPE_SUFFIX}" \ + --build-arg BASE_VERSION="${BASE_VERSION}" \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --platform="${PLATFORM}" \ --load \ diff --git a/ci/push_docker_multiplatform_manifest.sh b/ci/push_docker_multiplatform_manifest.sh index 7c802114c5..5ad382b87a 100755 --- a/ci/push_docker_multiplatform_manifest.sh +++ b/ci/push_docker_multiplatform_manifest.sh @@ -53,9 +53,16 @@ function push_manifest() { BUILD_PLATFORM="linux" ;; - "windows/amd64") + "windows/amd64/ltsc2022") BUILD_ARCH="amd64" BUILD_PLATFORM="windows" + BASE_VERSION="-ltsc2022" + ;; + + "windows/amd64/ltsc2019") + BUILD_ARCH="amd64" + BUILD_PLATFORM="windows" + BASE_VERSION="-ltsc2019" ;; *) echo "Unsupported platform ${platform}" @@ -63,7 +70,7 @@ function push_manifest() { ;; esac - TAGS_IN_MANIFEST+=("${REPO_URL}:${BUILD_TAG}${BUILD_TYPE_SUFFIX}-${BUILD_PLATFORM}-${BUILD_ARCH}") + TAGS_IN_MANIFEST+=("${REPO_URL}:${BUILD_TAG}${BUILD_TYPE_SUFFIX}-${BUILD_PLATFORM}-${BUILD_ARCH}${BASE_VERSION}") done echo "Tags in the manifest:"