From b17bd210c2fc69d122f073d3ddc7b4c995878bd4 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Mon, 26 Feb 2024 11:32:29 +0100 Subject: [PATCH 01/22] feat: add windows Dockerfile Signed-off-by: Dominik Rosiek --- .github/workflows/pull_requests.yml | 42 +++++++++++++++++++++++++++++ Dockerfile_windows | 3 +++ Makefile | 14 ++++++++++ 3 files changed, 59 insertions(+) create mode 100644 Dockerfile_windows diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 46a6b81071..b301bfba6d 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -359,3 +359,45 @@ jobs: - name: Test built FIPS image if: steps.changed-files.outputs.any_changed == 'true' && matrix.arch_os == 'linux_amd64' run: make test-built-image BUILD_TAG="latest-fips" + + build-windows-container: + name: Build windows container + runs-on: windows-2022 + needs: + - build + strategy: + matrix: + arch_os: [ 'windows_amd64'] + steps: + - uses: actions/checkout@v4 + + - name: Check if build related files changed + id: changed-files + uses: tj-actions/changed-files@v41 + with: + files: | + **/go.mod + **/go.sum + **/*.go + **/*.yaml + **/*.yml + **/Makefile + **/Makefile.common + **/Dockerfile* + + - name: Download binary action artifact from build phase + if: steps.changed-files.outputs.any_changed == 'true' + uses: actions/download-artifact@v4 + with: + name: otelcol-sumo-${{matrix.arch_os}} + path: artifacts/ + + - name: Build the container image + if: steps.changed-files.outputs.any_changed == 'true' + run: | + cp artifacts/otelcol-sumo-${{matrix.arch_os}} otelcol-sumo.exe + make build-push-container-windows + + - name: Test built image + if: steps.changed-files.outputs.any_changed == 'true' + run: make test-built-image diff --git a/Dockerfile_windows b/Dockerfile_windows new file mode 100644 index 0000000000..4e722a38f4 --- /dev/null +++ b/Dockerfile_windows @@ -0,0 +1,3 @@ +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 +ADD /otelcol-sumo.exe /otelcol-sumo.exe +ENTRYPOINT ["/otelcol-sumo.exe"] diff --git a/Makefile b/Makefile index 56b658b50e..4bff8d5635 100644 --- a/Makefile +++ b/Makefile @@ -300,6 +300,15 @@ _build-container-multiplatform: PLATFORM="$(PLATFORM)" \ ./ci/build-push-multiplatform.sh $(PUSH) +.PHONY: _build-container-windows +_build-container-windows: + docker \ + build \ + -f $(DOCKERFILE) \ + . \ + -t ${REPO_URL}/${BUILD_TAG}-windows \ + --platform="$(PLATFORM)" + .PHONY: build-container-multiplatform build-container-multiplatform: _build-container-multiplatform @@ -312,6 +321,11 @@ build-push-container-ubi: PUSH = --push build-push-container-ubi: DOCKERFILE = Dockerfile_ubi build-push-container-ubi: _build-container-multiplatform +.PHONY: build-push-container-windows +build-push-container-windows: PUSH = --push +build-push-container-windows: DOCKERFILE = Dockerfile_windows +build-push-container-windows: _build-container-windows + .PHONY: test-built-image test-built-image: docker run --rm "$(REPO_URL):$(BUILD_TAG)" --version From 2b1f4bc8e27ad09dfcf08ee73d15f064f6f85f69 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Mon, 26 Feb 2024 11:43:58 +0100 Subject: [PATCH 02/22] chore: force building container image Signed-off-by: Dominik Rosiek --- .github/workflows/pull_requests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index b301bfba6d..59d294cb5f 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -386,7 +386,7 @@ jobs: **/Dockerfile* - name: Download binary action artifact from build phase - if: steps.changed-files.outputs.any_changed == 'true' + # if: steps.changed-files.outputs.any_changed == 'true' uses: actions/download-artifact@v4 with: name: otelcol-sumo-${{matrix.arch_os}} From 64b30b785f35b6e4cbd55543e079bd76b20d4167 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Mon, 26 Feb 2024 12:25:11 +0100 Subject: [PATCH 03/22] chore: fix building image Signed-off-by: Dominik Rosiek --- .github/workflows/pull_requests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 59d294cb5f..96496e971f 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -386,7 +386,7 @@ jobs: **/Dockerfile* - name: Download binary action artifact from build phase - # if: steps.changed-files.outputs.any_changed == 'true' + if: steps.changed-files.outputs.any_changed == 'true' uses: actions/download-artifact@v4 with: name: otelcol-sumo-${{matrix.arch_os}} @@ -395,7 +395,7 @@ jobs: - name: Build the container image if: steps.changed-files.outputs.any_changed == 'true' run: | - cp artifacts/otelcol-sumo-${{matrix.arch_os}} otelcol-sumo.exe + cp artifacts/otelcol-sumo-${{matrix.arch_os}}.exe otelcol-sumo.exe make build-push-container-windows - name: Test built image From d073877d9183c29ba5a2a52a1ce37c283332d59e Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Mon, 26 Feb 2024 13:19:30 +0100 Subject: [PATCH 04/22] fix: fix artifact name Signed-off-by: Dominik Rosiek --- .github/workflows/pull_requests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 96496e971f..969c63d03b 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -389,7 +389,7 @@ jobs: if: steps.changed-files.outputs.any_changed == 'true' uses: actions/download-artifact@v4 with: - name: otelcol-sumo-${{matrix.arch_os}} + name: otelcol-sumo-${{matrix.arch_os}}.exe path: artifacts/ - name: Build the container image From 580853c778e5ed2291e4c2396c55a43a2ce3587b Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Tue, 27 Feb 2024 22:03:12 +0100 Subject: [PATCH 05/22] feat: support bulding windows image in ci/build-push-multiplatform.sh Signed-off-by: Dominik Rosiek --- .github/workflows/pull_requests.yml | 4 +- Dockerfile_windows | 6 +- Makefile | 11 +-- ci/build-push-multiplatform.sh | 115 ++++++++++++++++------- ci/push_docker_multiplatform_manifest.sh | 15 ++- 5 files changed, 101 insertions(+), 50 deletions(-) diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 969c63d03b..f20dbf4a62 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -396,7 +396,9 @@ jobs: if: steps.changed-files.outputs.any_changed == 'true' run: | cp artifacts/otelcol-sumo-${{matrix.arch_os}}.exe otelcol-sumo.exe - make build-push-container-windows + make build-container-multiplatform \ + PLATFORM=${{ matrix.arch_os }} \ + DOCKERFILE=Dockerfile_windows - name: Test built image if: steps.changed-files.outputs.any_changed == 'true' diff --git a/Dockerfile_windows b/Dockerfile_windows index 4e722a38f4..2c25ca6a71 100644 --- a/Dockerfile_windows +++ b/Dockerfile_windows @@ -1,3 +1,7 @@ -FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 +FROM mcr.microsoft.com/windows/servercore:ltsc2019 +ARG BUILD_TAG=latest +ENV TAG $BUILD_TAG + ADD /otelcol-sumo.exe /otelcol-sumo.exe ENTRYPOINT ["/otelcol-sumo.exe"] +CMD ["--config", "/etc/otel/config.yaml"] diff --git a/Makefile b/Makefile index 4bff8d5635..c3186f0fa0 100644 --- a/Makefile +++ b/Makefile @@ -300,15 +300,6 @@ _build-container-multiplatform: PLATFORM="$(PLATFORM)" \ ./ci/build-push-multiplatform.sh $(PUSH) -.PHONY: _build-container-windows -_build-container-windows: - docker \ - build \ - -f $(DOCKERFILE) \ - . \ - -t ${REPO_URL}/${BUILD_TAG}-windows \ - --platform="$(PLATFORM)" - .PHONY: build-container-multiplatform build-container-multiplatform: _build-container-multiplatform @@ -324,7 +315,7 @@ build-push-container-ubi: _build-container-multiplatform .PHONY: build-push-container-windows build-push-container-windows: PUSH = --push build-push-container-windows: DOCKERFILE = Dockerfile_windows -build-push-container-windows: _build-container-windows +build-push-container-windows: _build-container-multiplatform .PHONY: test-built-image test-built-image: diff --git a/ci/build-push-multiplatform.sh b/ci/build-push-multiplatform.sh index f2844e23d0..d84395331a 100755 --- a/ci/build-push-multiplatform.sh +++ b/ci/build-push-multiplatform.sh @@ -2,21 +2,29 @@ set -eo pipefail -while ! docker buildx ls; do - echo "Cannot connect to docker daemon" - sleep 1 -done - -DOCKER_BUILDX_LS_OUT=$(docker buildx ls <<-END +if echo "${PLATFORM}" | grep windows; then + echo '' + # while ! docker images; do + # echo "Cannot connect to docker daemon" + # sleep 1 + # done +else + while ! docker buildx ls; do + echo "Cannot connect to docker daemon" + sleep 1 + done + + DOCKER_BUILDX_LS_OUT=$(docker buildx ls <<-END END -) -readonly DOCKER_BUILDX_LS_OUT + ) + readonly DOCKER_BUILDX_LS_OUT -# check for arm support only if we try to build it -if echo "${PLATFORM}" | grep -q arm && ! grep -q arm <<< "${DOCKER_BUILDX_LS_OUT}"; then - echo "Your Buildx seems to lack ARM architecture support" - echo "${DOCKER_BUILDX_LS_OUT}" - exit 1 + # check for arm support only if we try to build it + if echo "${PLATFORM}" | grep -q arm && ! grep -q arm <<< "${DOCKER_BUILDX_LS_OUT}"; then + echo "Your Buildx seems to lack ARM architecture support" + echo "${DOCKER_BUILDX_LS_OUT}" + exit 1 + fi fi if [[ -z "${BUILD_TAG}" ]]; then @@ -57,14 +65,22 @@ function build_push() { case "${PLATFORM}" in "linux/amd64"|"linux_amd64") readonly BUILD_ARCH="amd64" + readonly BUILD_PLATFORM="linux" PLATFORM="linux/amd64" ;; "linux/arm64"|"linux_arm64") readonly BUILD_ARCH="arm64" + readonly BUILD_PLATFORM="linux" PLATFORM="linux/arm64" ;; + "windows/amd64"|"windows_amd64") + readonly BUILD_ARCH="amd64" + readonly BUILD_PLATFORM="windows" + 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 @@ -82,33 +98,64 @@ function build_push() { esac local TAG - readonly TAG="${REPO_URL}:${BUILD_TAG}${BUILD_TYPE_SUFFIX}-${BUILD_ARCH}" + readonly TAG="${REPO_URL}:${BUILD_TAG}${BUILD_TYPE_SUFFIX}-${BUILD_PLATFORM}-${BUILD_ARCH}" local LATEST_TAG - readonly LATEST_TAG="${REPO_URL}:latest${BUILD_TYPE_SUFFIX}-${BUILD_ARCH}" + readonly LATEST_TAG="${REPO_URL}:latest${BUILD_TYPE_SUFFIX}-${BUILD_PLATFORM}-${BUILD_ARCH}" if [[ "${PUSH}" == true ]]; then echo "Building tags: ${TAG}, ${LATEST_TAG}" - docker buildx build \ - --push \ - --file "${DOCKERFILE}" \ - --build-arg BUILD_TAG="${BUILD_TAG}" \ - --build-arg BUILDKIT_INLINE_CACHE=1 \ - --platform="${PLATFORM}" \ - --tag "${LATEST_TAG}" \ - --tag "${TAG}" \ - . + + if [[ "${BUILD_PLATFORM}" == "windows" ]]; then + docker build \ + --file "${DOCKERFILE}" \ + --build-arg BUILD_TAG="${BUILD_TAG}" \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --platform="${PLATFORM}" \ + --tag "${LATEST_TAG}" \ + . + + docker tag "${LATEST_TAG}" "${TAG}" + + docker push "${LATEST_TAG}" + docker push "${TAG}" + else + docker buildx build \ + --push \ + --file "${DOCKERFILE}" \ + --build-arg BUILD_TAG="${BUILD_TAG}" \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --platform="${PLATFORM}" \ + --tag "${LATEST_TAG}" \ + --tag "${TAG}" \ + . + fi else echo "Building tag: latest${BUILD_TYPE_SUFFIX}" - # load flag is needed so that docker loads this image - # for subsequent steps on github actions - docker buildx build \ - --file "${DOCKERFILE}" \ - --build-arg BUILD_TAG="latest${BUILD_TYPE_SUFFIX}" \ - --build-arg BUILDKIT_INLINE_CACHE=1 \ - --platform="${PLATFORM}" \ - --load \ - --tag "${REPO_URL}:latest${BUILD_TYPE_SUFFIX}" \ - . + if [[ "${BUILD_PLATFORM}" == "windows" ]]; then + docker build \ + --file "${DOCKERFILE}" \ + --build-arg BUILD_TAG="${BUILD_TAG}" \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --platform="${PLATFORM}" \ + --tag "${REPO_URL}:latest${BUILD_TYPE_SUFFIX}" \ + . + + docker tag "${LATEST_TAG}" "${TAG}" + + docker push "${LATEST_TAG}" + docker push "${TAG}" + else + # load flag is needed so that docker loads this image + # for subsequent steps on github actions + docker buildx build \ + --file "${DOCKERFILE}" \ + --build-arg BUILD_TAG="latest${BUILD_TYPE_SUFFIX}" \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --platform="${PLATFORM}" \ + --load \ + --tag "${REPO_URL}:latest${BUILD_TYPE_SUFFIX}" \ + . + fi fi } diff --git a/ci/push_docker_multiplatform_manifest.sh b/ci/push_docker_multiplatform_manifest.sh index 13003900d1..71868b9ea1 100755 --- a/ci/push_docker_multiplatform_manifest.sh +++ b/ci/push_docker_multiplatform_manifest.sh @@ -39,24 +39,31 @@ function push_manifest() { echo "${platform}" case "${platform}" in "linux/amd64") - BUILD_ARCH="amd64" + readonly BUILD_ARCH="amd64" + readonly BUILD_PLATFORM="linux" ;; "linux/arm64") - BUILD_ARCH="arm64" + readonly BUILD_ARCH="arm64" + readonly BUILD_PLATFORM="linux" ;; "linux/arm/v7") - BUILD_ARCH="arm_v7" + readonly BUILD_ARCH="arm_v7" + readonly BUILD_PLATFORM="linux" ;; + "windows/amd64") + readonly BUILD_ARCH="amd64" + readonly BUILD_PLATFORM="windows" + ;; *) echo "Unsupported platform ${platform}" exit 1 ;; esac - TAGS_IN_MANIFEST+=("${REPO_URL}:${BUILD_TAG}-${BUILD_ARCH}") + TAGS_IN_MANIFEST+=("${REPO_URL}:${BUILD_TAG}-${BUILD_PLATFORM}-${BUILD_ARCH}") done echo "Tags in the manifest:" From 94068b1e12710f19a7888102b8532d8a9c1467b9 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Tue, 27 Feb 2024 22:54:19 +0100 Subject: [PATCH 06/22] fix: fix building windows image Signed-off-by: Dominik Rosiek --- .github/workflows/pull_requests.yml | 14 ++++++++++++++ Dockerfile_windows | 2 +- ci/build-push-multiplatform.sh | 7 +------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index f20dbf4a62..9895ccdf91 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -403,3 +403,17 @@ jobs: - name: Test built image if: steps.changed-files.outputs.any_changed == 'true' run: make test-built-image + + # ToDo: build windows FIPS image + # - name: Build the FIPS container image + # if: steps.changed-files.outputs.any_changed == 'true' + # run: | + # cp artifacts/otelcol-sumo-fips-${{matrix.arch_os}}.exe otelcol-sumo.exe + # make build-container-multiplatform \ + # PLATFORM=${{ matrix.arch_os }} \ + # DOCKERFILE=Dockerfile_windows \ + # BUILD_TYPE_SUFFIX="-fips" + + # - name: Test built FIPS image + # if: steps.changed-files.outputs.any_changed == 'true' + # run: make test-built-image BUILD_TAG="latest-fips" diff --git a/Dockerfile_windows b/Dockerfile_windows index 2c25ca6a71..14ada642d9 100644 --- a/Dockerfile_windows +++ b/Dockerfile_windows @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/windows/servercore:ltsc2019 +FROM mcr.microsoft.com/windows/servercore:ltsc2022 ARG BUILD_TAG=latest ENV TAG $BUILD_TAG diff --git a/ci/build-push-multiplatform.sh b/ci/build-push-multiplatform.sh index d84395331a..feda4295ed 100755 --- a/ci/build-push-multiplatform.sh +++ b/ci/build-push-multiplatform.sh @@ -134,16 +134,11 @@ function build_push() { if [[ "${BUILD_PLATFORM}" == "windows" ]]; then docker build \ --file "${DOCKERFILE}" \ - --build-arg BUILD_TAG="${BUILD_TAG}" \ + --build-arg BUILD_TAG="latest${BUILD_TYPE_SUFFIX}" \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --platform="${PLATFORM}" \ --tag "${REPO_URL}:latest${BUILD_TYPE_SUFFIX}" \ . - - docker tag "${LATEST_TAG}" "${TAG}" - - docker push "${LATEST_TAG}" - docker push "${TAG}" else # load flag is needed so that docker loads this image # for subsequent steps on github actions From eee5129887784b7f1ab6ce8a89a882bc3140ef6b Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Wed, 28 Feb 2024 08:47:32 +0100 Subject: [PATCH 07/22] chore: add dev-builds Signed-off-by: Dominik Rosiek --- .github/workflows/dev_builds.yml | 46 ++++++++++++++++++++++++++++- .github/workflows/pull_requests.yml | 10 +++---- Makefile | 17 +++++++---- 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml index 92681b4ed4..035e3363f0 100644 --- a/.github/workflows/dev_builds.yml +++ b/.github/workflows/dev_builds.yml @@ -5,6 +5,7 @@ on: branches: - main - 'dev-build/*' + - drosiek-windows-container defaults: run: @@ -191,11 +192,54 @@ jobs: PLATFORM=${{ matrix.arch_os }} \ BUILD_TYPE_SUFFIX="-ubi" + build-windows-container-images: + name: Build Windows container + runs-on: windows-2022 + needs: + - build + strategy: + matrix: + arch_os: [ 'windows_amd64'] + steps: + - uses: actions/checkout@v4 + + - name: Extract tag + id: extract_tag + run: echo "tag=$(git rev-parse HEAD)" > $GITHUB_OUTPUT + + - name: Print tag + run: echo "Running dev build for ${{ steps.extract_tag.outputs.tag }}" + + - name: Login to Open Source ECR + run: | + USERNAME=$(powershell.exe "echo \$Env:UserName") + # remove wincred entry and fix json format by replacing }, with } + cat "C:\\Users\\${USERNAME}\\.docker\\config.json" | grep -v "wincred" | sed 's/},$/}/' > "C:\\Users\\${USERNAME}\\.docker\\config.json.tmp" + mv "C:\\Users\\${USERNAME}\\.docker\\config.json.tmp" "C:\\Users\\${USERNAME}\\.docker\\config.json" + make login + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }} + + - name: Download binary action artifact from build phase + uses: actions/download-artifact@v4 + with: + name: otelcol-sumo-${{matrix.arch_os}}.exe + path: artifacts/ + + - name: Build and push image 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 }} + push-docker-manifest: name: Push joint container manifest runs-on: ubuntu-20.04 needs: - build-container-images + - build-windows-container-images steps: - uses: actions/checkout@v4 @@ -240,7 +284,7 @@ jobs: run: | make push-container-manifest-dev \ BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \ - PLATFORMS="linux/amd64 linux/arm64" + PLATFORMS="linux/amd64 linux/arm64 windows/amd64" - 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 9895ccdf91..1927c5d35d 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -396,9 +396,8 @@ jobs: if: steps.changed-files.outputs.any_changed == 'true' run: | cp artifacts/otelcol-sumo-${{matrix.arch_os}}.exe otelcol-sumo.exe - make build-container-multiplatform \ - PLATFORM=${{ matrix.arch_os }} \ - DOCKERFILE=Dockerfile_windows + make build-container-windows \ + PLATFORM=${{ matrix.arch_os }} - name: Test built image if: steps.changed-files.outputs.any_changed == 'true' @@ -409,9 +408,8 @@ jobs: # if: steps.changed-files.outputs.any_changed == 'true' # run: | # cp artifacts/otelcol-sumo-fips-${{matrix.arch_os}}.exe otelcol-sumo.exe - # make build-container-multiplatform \ - # PLATFORM=${{ matrix.arch_os }} \ - # DOCKERFILE=Dockerfile_windows \ + # make build-container-windows \ + # PLATFORM=${{ matrix.arch_os }} # BUILD_TYPE_SUFFIX="-fips" # - name: Test built FIPS image diff --git a/Makefile b/Makefile index c3186f0fa0..d5e8dc0313 100644 --- a/Makefile +++ b/Makefile @@ -280,6 +280,10 @@ build-container-multiplatform-dev: build-container-multiplatform build-push-container-multiplatform-dev: REPO_URL = "$(OPENSOURCE_REPO_URL_DEV)" build-push-container-multiplatform-dev: build-push-container-multiplatform +.PHONY: build-push-container-windows-dev +build-push-container-windows-dev: DOCKERFILE = Dockerfile_windows +build-push-container-windows-dev: build-push-container-multiplatform-dev + .PHONY: push-container-manifest-dev push-container-manifest-dev: REPO_URL = "$(OPENSOURCE_REPO_URL_DEV)" push-container-manifest-dev: push-container-manifest @@ -303,6 +307,14 @@ _build-container-multiplatform: .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 + +.PHONY: build-push-container-windows +build-push-container-windows: PUSH = --push +build-push-container-windows: build-container-windows + .PHONY: build-push-container-multiplatform build-push-container-multiplatform: PUSH = --push build-push-container-multiplatform: _build-container-multiplatform @@ -312,11 +324,6 @@ build-push-container-ubi: PUSH = --push build-push-container-ubi: DOCKERFILE = Dockerfile_ubi build-push-container-ubi: _build-container-multiplatform -.PHONY: build-push-container-windows -build-push-container-windows: PUSH = --push -build-push-container-windows: DOCKERFILE = Dockerfile_windows -build-push-container-windows: _build-container-multiplatform - .PHONY: test-built-image test-built-image: docker run --rm "$(REPO_URL):$(BUILD_TAG)" --version From 07b0f529c89681eb43efab5cff914fbc7168e453 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Wed, 28 Feb 2024 12:01:54 +0100 Subject: [PATCH 08/22] chore: fix due to bash syntax issues Signed-off-by: Dominik Rosiek --- ci/push_docker_multiplatform_manifest.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ci/push_docker_multiplatform_manifest.sh b/ci/push_docker_multiplatform_manifest.sh index 71868b9ea1..11c964cd52 100755 --- a/ci/push_docker_multiplatform_manifest.sh +++ b/ci/push_docker_multiplatform_manifest.sh @@ -39,23 +39,23 @@ function push_manifest() { echo "${platform}" case "${platform}" in "linux/amd64") - readonly BUILD_ARCH="amd64" - readonly BUILD_PLATFORM="linux" + BUILD_ARCH="amd64" + BUILD_PLATFORM="linux" ;; "linux/arm64") - readonly BUILD_ARCH="arm64" - readonly BUILD_PLATFORM="linux" + BUILD_ARCH="arm64" + BUILD_PLATFORM="linux" ;; "linux/arm/v7") - readonly BUILD_ARCH="arm_v7" - readonly BUILD_PLATFORM="linux" + BUILD_ARCH="arm_v7" + BUILD_PLATFORM="linux" ;; "windows/amd64") - readonly BUILD_ARCH="amd64" - readonly BUILD_PLATFORM="windows" + BUILD_ARCH="amd64" + BUILD_PLATFORM="windows" ;; *) echo "Unsupported platform ${platform}" From e0368dc82f92456a100ee13cb2fb4d0223364b0d Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Wed, 28 Feb 2024 14:24:14 +0100 Subject: [PATCH 09/22] feat: do not push attestation manifest Signed-off-by: Dominik Rosiek --- ci/build-push-multiplatform.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/build-push-multiplatform.sh b/ci/build-push-multiplatform.sh index feda4295ed..253efb63f4 100755 --- a/ci/build-push-multiplatform.sh +++ b/ci/build-push-multiplatform.sh @@ -127,6 +127,7 @@ function build_push() { --platform="${PLATFORM}" \ --tag "${LATEST_TAG}" \ --tag "${TAG}" \ + --provenance=false \ . fi else From bdda2f63cee4f78cd72faa74bc4fa1b50e81d266 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Wed, 28 Feb 2024 15:20:03 +0100 Subject: [PATCH 10/22] chore: use docker manifest instead of docker buildx Signed-off-by: Dominik Rosiek --- ci/push_docker_multiplatform_manifest.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ci/push_docker_multiplatform_manifest.sh b/ci/push_docker_multiplatform_manifest.sh index 11c964cd52..437c64805d 100755 --- a/ci/push_docker_multiplatform_manifest.sh +++ b/ci/push_docker_multiplatform_manifest.sh @@ -74,13 +74,20 @@ function push_manifest() { echo set -x - docker buildx imagetools create --tag \ + # Use docker manifest as docker buildx didn't create "${REPO_URL}:${BUILD_TAG}" correctly. It was containing only linux/amd64 image + docker manifest create \ "${REPO_URL}:${BUILD_TAG}" \ "${TAGS_IN_MANIFEST[@]}" - docker buildx imagetools create --tag \ + docker manifest push \ + "${REPO_URL}:${BUILD_TAG}" + + docker manifest create \ "${REPO_URL}:latest${BUILD_TYPE_SUFFIX}" \ "${TAGS_IN_MANIFEST[@]}" + + docker manifest push \ + "${REPO_URL}:latest${BUILD_TYPE_SUFFIX}" } push_manifest From 3d0f405866e76a376da57778f64950900768e7ea Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Wed, 28 Feb 2024 17:11:22 +0100 Subject: [PATCH 11/22] chore: add suffix to image tag Signed-off-by: Dominik Rosiek --- ci/push_docker_multiplatform_manifest.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/push_docker_multiplatform_manifest.sh b/ci/push_docker_multiplatform_manifest.sh index 437c64805d..7c802114c5 100755 --- a/ci/push_docker_multiplatform_manifest.sh +++ b/ci/push_docker_multiplatform_manifest.sh @@ -63,7 +63,7 @@ function push_manifest() { ;; esac - TAGS_IN_MANIFEST+=("${REPO_URL}:${BUILD_TAG}-${BUILD_PLATFORM}-${BUILD_ARCH}") + TAGS_IN_MANIFEST+=("${REPO_URL}:${BUILD_TAG}${BUILD_TYPE_SUFFIX}-${BUILD_PLATFORM}-${BUILD_ARCH}") done echo "Tags in the manifest:" @@ -76,11 +76,11 @@ function push_manifest() { set -x # Use docker manifest as docker buildx didn't create "${REPO_URL}:${BUILD_TAG}" correctly. It was containing only linux/amd64 image docker manifest create \ - "${REPO_URL}:${BUILD_TAG}" \ + "${REPO_URL}:${BUILD_TAG}${BUILD_TYPE_SUFFIX}" \ "${TAGS_IN_MANIFEST[@]}" docker manifest push \ - "${REPO_URL}:${BUILD_TAG}" + "${REPO_URL}:${BUILD_TAG}${BUILD_TYPE_SUFFIX}" docker manifest create \ "${REPO_URL}:latest${BUILD_TYPE_SUFFIX}" \ From a9a5bbe183c9d0505a3b6724afb93251d48be3f2 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Wed, 28 Feb 2024 19:09:44 +0100 Subject: [PATCH 12/22] feat: add building windows containers for releases Signed-off-by: Dominik Rosiek --- .github/workflows/release_builds.yml | 45 +++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release_builds.yml b/.github/workflows/release_builds.yml index ea2b7abea8..ebe5b3199c 100644 --- a/.github/workflows/release_builds.yml +++ b/.github/workflows/release_builds.yml @@ -385,6 +385,48 @@ jobs: PLATFORM=${{ matrix.arch_os }} BUILD_TYPE_SUFFIX="-ubi" + build-windows-container-images: + name: Build Windows container + runs-on: windows-2022 + needs: + - build + strategy: + matrix: + arch_os: [ 'windows_amd64'] + steps: + - uses: actions/checkout@v4 + + - name: Extract tag + id: extract_tag + run: echo "tag=$(git rev-parse HEAD)" > $GITHUB_OUTPUT + + - name: Print tag + run: echo "Running dev build for ${{ steps.extract_tag.outputs.tag }}" + + - name: Login to Open Source ECR + run: | + USERNAME=$(powershell.exe "echo \$Env:UserName") + # remove wincred entry and fix json format by replacing }, with } + cat "C:\\Users\\${USERNAME}\\.docker\\config.json" | grep -v "wincred" | sed 's/},$/}/' > "C:\\Users\\${USERNAME}\\.docker\\config.json.tmp" + mv "C:\\Users\\${USERNAME}\\.docker\\config.json.tmp" "C:\\Users\\${USERNAME}\\.docker\\config.json" + make login + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }} + + - name: Download binary action artifact from build phase + uses: actions/download-artifact@v4 + with: + name: otelcol-sumo-${{matrix.arch_os}}.exe + path: artifacts/ + + - name: Build and push image to Open Source ECR + run: | + cp artifacts/otelcol-sumo-${{matrix.arch_os}}.exe otelcol-sumo.exe + make build-push-container-windows \ + BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \ + PLATFORM=${{ matrix.arch_os }} + push-docker-manifest: name: Push joint container manifest runs-on: ubuntu-20.04 @@ -393,6 +435,7 @@ jobs: # when darwin build fails. - build-darwin - build-container-images + - build-windows-container-images steps: - uses: actions/checkout@v4 @@ -437,7 +480,7 @@ jobs: run: | make push-container-manifest \ BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \ - PLATFORMS="linux/amd64 linux/arm64" + PLATFORMS="linux/amd64 linux/arm64 windows/amd64" - name: Push joint UBI-based container manifest for all platforms to Open Source ECR run: | From 2493756dfd9294430498cbf993a80b7e4528e89e Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Wed, 28 Feb 2024 19:15:21 +0100 Subject: [PATCH 13/22] chore: changelog Signed-off-by: Dominik Rosiek --- .changelog/1467.added.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 .changelog/1467.added.txt diff --git a/.changelog/1467.added.txt b/.changelog/1467.added.txt new file mode 100644 index 0000000000..491c82e5f5 --- /dev/null +++ b/.changelog/1467.added.txt @@ -0,0 +1 @@ +feat: build windows containers \ No newline at end of file From 787cafa85bf263c047cac688e0ebef26eefff49d Mon Sep 17 00:00:00 2001 From: Dominik Rosiek <58699848+sumo-drosiek@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:17:39 +0100 Subject: [PATCH 14/22] Update ci/build-push-multiplatform.sh --- ci/build-push-multiplatform.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ci/build-push-multiplatform.sh b/ci/build-push-multiplatform.sh index 253efb63f4..c8cfdcfeeb 100755 --- a/ci/build-push-multiplatform.sh +++ b/ci/build-push-multiplatform.sh @@ -3,11 +3,10 @@ set -eo pipefail if echo "${PLATFORM}" | grep windows; then - echo '' - # while ! docker images; do - # echo "Cannot connect to docker daemon" - # sleep 1 - # done + while ! docker images; do + echo "Cannot connect to docker daemon" + sleep 1 + done else while ! docker buildx ls; do echo "Cannot connect to docker daemon" From a8185a6dd767be47e268dd4e98d328e2559ec21b Mon Sep 17 00:00:00 2001 From: Dominik Rosiek <58699848+sumo-drosiek@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:19:04 +0100 Subject: [PATCH 15/22] Update ci/build-push-multiplatform.sh --- ci/build-push-multiplatform.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/build-push-multiplatform.sh b/ci/build-push-multiplatform.sh index c8cfdcfeeb..be9de7c393 100755 --- a/ci/build-push-multiplatform.sh +++ b/ci/build-push-multiplatform.sh @@ -149,6 +149,7 @@ function build_push() { --platform="${PLATFORM}" \ --load \ --tag "${REPO_URL}:latest${BUILD_TYPE_SUFFIX}" \ + --provenance=false \ . fi fi From 8e2b4e82f6fc32899d166b88597d27f8120eccc3 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Thu, 29 Feb 2024 08:05:40 +0100 Subject: [PATCH 16/22] chore: add comment due to review Signed-off-by: Dominik Rosiek --- ci/build-push-multiplatform.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/build-push-multiplatform.sh b/ci/build-push-multiplatform.sh index be9de7c393..1d7c1d2b0d 100755 --- a/ci/build-push-multiplatform.sh +++ b/ci/build-push-multiplatform.sh @@ -101,6 +101,7 @@ function build_push() { local LATEST_TAG readonly LATEST_TAG="${REPO_URL}:latest${BUILD_TYPE_SUFFIX}-${BUILD_PLATFORM}-${BUILD_ARCH}" + # --provenance=false for docker buildx ensures that we create manifest instead of manifest list if [[ "${PUSH}" == true ]]; then echo "Building tags: ${TAG}, ${LATEST_TAG}" From 8b82ae560eaef0ace1c9b1e1cd87f4b46901c8e0 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Thu, 29 Feb 2024 08:54:37 +0100 Subject: [PATCH 17/22] chore: build multiple windows images Signed-off-by: Dominik Rosiek --- .github/workflows/dev_builds.yml | 12 ++++++---- .github/workflows/pull_requests.yml | 26 ++++++++++----------- .github/workflows/release_builds.yml | 10 +++++--- Dockerfile_windows | 3 ++- Makefile | 12 ++++++++-- ci/build-push-multiplatform.sh | 29 ++++++++++++++++++++++-- ci/push_docker_multiplatform_manifest.sh | 11 +++++++-- 7 files changed, 75 insertions(+), 28 deletions(-) diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml index 035e3363f0..41e8dc601e 100644 --- a/.github/workflows/dev_builds.yml +++ b/.github/workflows/dev_builds.yml @@ -199,7 +199,11 @@ jobs: - build strategy: matrix: - arch_os: [ 'windows_amd64'] + include: + - arch_os: windows_amd64 + base_image_tag: ltsc2022 + - arch_os: windows_amd64 + base_image_tag: ltsc2019 steps: - uses: actions/checkout@v4 @@ -227,12 +231,12 @@ 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 }}_${{ matrix.base_image_tag }} push-docker-manifest: name: Push joint container manifest @@ -284,7 +288,7 @@ jobs: 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 1927c5d35d..3c15ebce07 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -362,12 +362,21 @@ jobs: build-windows-container: name: Build windows container - runs-on: windows-2022 needs: - build strategy: matrix: - arch_os: [ 'windows_amd64'] + include: + - arch_os: windows_amd64 + base_image_tag: ltsc2022 + runs-on: windows-2022 + - arch_os: windows_amd64 + base_image_tag: ltsc2019 + runs-on: windows-2019 + with: + arch_os: ${{ matrix.arch_os }} + runs-on: ${{ matrix.runs-on }} + base_image_tag: ${{ matrix.base_image_tag }} steps: - uses: actions/checkout@v4 @@ -397,21 +406,10 @@ 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 }}_${{ matrix.base_image_tag }} - name: Test built image if: steps.changed-files.outputs.any_changed == 'true' run: make test-built-image # ToDo: build windows FIPS image - # - name: Build the FIPS container image - # if: steps.changed-files.outputs.any_changed == 'true' - # run: | - # cp artifacts/otelcol-sumo-fips-${{matrix.arch_os}}.exe otelcol-sumo.exe - # make build-container-windows \ - # PLATFORM=${{ matrix.arch_os }} - # BUILD_TYPE_SUFFIX="-fips" - - # - name: Test built FIPS image - # if: steps.changed-files.outputs.any_changed == 'true' - # run: make test-built-image BUILD_TAG="latest-fips" diff --git a/.github/workflows/release_builds.yml b/.github/workflows/release_builds.yml index ebe5b3199c..946ff303c9 100644 --- a/.github/workflows/release_builds.yml +++ b/.github/workflows/release_builds.yml @@ -392,7 +392,11 @@ jobs: - build strategy: matrix: - arch_os: [ 'windows_amd64'] + include: + - arch_os: windows_amd64 + base_image_tag: ltsc2022 + - arch_os: windows_amd64 + base_image_tag: ltsc2019 steps: - uses: actions/checkout@v4 @@ -425,7 +429,7 @@ jobs: cp artifacts/otelcol-sumo-${{matrix.arch_os}}.exe otelcol-sumo.exe make build-push-container-windows \ BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \ - PLATFORM=${{ matrix.arch_os }} + PLATFORM=${{ matrix.arch_os }}_${{ matrix.base_image_tag }} push-docker-manifest: name: Push joint container manifest @@ -480,7 +484,7 @@ jobs: run: | make push-container-manifest \ 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/Dockerfile_windows b/Dockerfile_windows index 14ada642d9..87887b953a 100644 --- a/Dockerfile_windows +++ b/Dockerfile_windows @@ -1,4 +1,5 @@ -FROM mcr.microsoft.com/windows/servercore:ltsc2022 +ARG BASE_IMAGE_TAG=ltsc2022 +FROM mcr.microsoft.com/windows/servercore:${BASE_IMAGE_TAG} ARG BUILD_TAG=latest ENV TAG $BUILD_TAG diff --git a/Makefile b/Makefile index d5e8dc0313..2c2c9c228e 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_IMAGE_TAG ?= "" DOCKERFILE = Dockerfile @@ -302,14 +303,21 @@ _build-container-multiplatform: REPO_URL="$(REPO_URL)" \ DOCKERFILE="$(DOCKERFILE)" \ PLATFORM="$(PLATFORM)" \ + BASE_IMAGE_TAG="${BASE_IMAGE_TAG}" \ ./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_IMAGE_TAG=ltsc2022 + + $(MAKE) _build-container-multiplatform \ + DOCKERFILE=Dockerfile_windows \ + BASE_IMAGE_TAG=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..8fac78389e 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_IMAGE_TAG}" ]]; then + BASE_IMAGE_TAG="-${BASE_IMAGE_TAG}" +fi + if [[ -z "${PLATFORM}" ]]; then echo "No PLATFORM passed in" exit 1 @@ -59,6 +63,7 @@ fi # linux/arm/v7, linux/arm/v6 function build_push() { local BUILD_ARCH + local BASE_IMAGE_TAG_SUFFIX set -x case "${PLATFORM}" in @@ -75,8 +80,24 @@ function build_push() { ;; "windows/amd64"|"windows_amd64") + readonly BUILD_ARCH="amd64" + readonly BASE_IMAGE_TAG_SUFFIX="windows" + PLATFORM="windows/amd64" + ;; + + "windows/amd64/ltsc2022"|"windows_amd64_ltsc2022") + readonly BUILD_ARCH="amd64" + readonly BUILD_PLATFORM="windows" + readonly BASE_IMAGE_TAG_SUFFIX="-ltsc2022" + readonly BASE_IMAGE_TAG="ltsc2022" + PLATFORM="windows/amd64" + ;; + + "windows/amd64/ltsc2019"|"windows_amd64_ltsc2019") readonly BUILD_ARCH="amd64" readonly BUILD_PLATFORM="windows" + readonly BASE_IMAGE_TAG_SUFFIX="-ltsc2019" + readonly BASE_IMAGE_TAG="ltsc2019" PLATFORM="windows/amd64" ;; @@ -97,9 +118,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_IMAGE_TAG_SUFFIX}" 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_IMAGE_TAG_SUFFIX}" # --provenance=false for docker buildx ensures that we create manifest instead of manifest list if [[ "${PUSH}" == true ]]; then @@ -109,6 +130,7 @@ function build_push() { docker build \ --file "${DOCKERFILE}" \ --build-arg BUILD_TAG="${BUILD_TAG}" \ + --build-arg BASE_IMAGE_TAG="${BASE_IMAGE_TAG}" \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --platform="${PLATFORM}" \ --tag "${LATEST_TAG}" \ @@ -123,6 +145,7 @@ function build_push() { --push \ --file "${DOCKERFILE}" \ --build-arg BUILD_TAG="${BUILD_TAG}" \ + --build-arg BASE_IMAGE_TAG="${BASE_IMAGE_TAG}" \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --platform="${PLATFORM}" \ --tag "${LATEST_TAG}" \ @@ -136,6 +159,7 @@ function build_push() { docker build \ --file "${DOCKERFILE}" \ --build-arg BUILD_TAG="latest${BUILD_TYPE_SUFFIX}" \ + --build-arg BASE_IMAGE_TAG="${BASE_IMAGE_TAG}" \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --platform="${PLATFORM}" \ --tag "${REPO_URL}:latest${BUILD_TYPE_SUFFIX}" \ @@ -146,6 +170,7 @@ function build_push() { docker buildx build \ --file "${DOCKERFILE}" \ --build-arg BUILD_TAG="latest${BUILD_TYPE_SUFFIX}" \ + --build-arg BASE_IMAGE_TAG="${BASE_IMAGE_TAG}" \ --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..d495b4cfa2 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_IMAGE_TAG_SUFFIX="-ltsc2022" + ;; + + "windows/amd64/ltsc2019") + BUILD_ARCH="amd64" + BUILD_PLATFORM="windows" + BASE_IMAGE_TAG_SUFFIX="-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_IMAGE_TAG_SUFFIX}") done echo "Tags in the manifest:" From 27adea3e89e307a072a5fae30a5d7be537cc31c6 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Thu, 29 Feb 2024 14:21:12 +0100 Subject: [PATCH 18/22] chore: do not release windows containers Signed-off-by: Dominik Rosiek --- .github/workflows/pull_requests.yml | 5 +-- .github/workflows/release_builds.yml | 49 +--------------------------- 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 3c15ebce07..c2dadde947 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -364,6 +364,7 @@ jobs: name: Build windows container needs: - build + runs-on: ${{ matrix.runs_on }} strategy: matrix: include: @@ -373,10 +374,6 @@ jobs: - arch_os: windows_amd64 base_image_tag: ltsc2019 runs-on: windows-2019 - with: - arch_os: ${{ matrix.arch_os }} - runs-on: ${{ matrix.runs-on }} - base_image_tag: ${{ matrix.base_image_tag }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release_builds.yml b/.github/workflows/release_builds.yml index 946ff303c9..ea2b7abea8 100644 --- a/.github/workflows/release_builds.yml +++ b/.github/workflows/release_builds.yml @@ -385,52 +385,6 @@ jobs: PLATFORM=${{ matrix.arch_os }} BUILD_TYPE_SUFFIX="-ubi" - build-windows-container-images: - name: Build Windows container - runs-on: windows-2022 - needs: - - build - strategy: - matrix: - include: - - arch_os: windows_amd64 - base_image_tag: ltsc2022 - - arch_os: windows_amd64 - base_image_tag: ltsc2019 - steps: - - uses: actions/checkout@v4 - - - name: Extract tag - id: extract_tag - run: echo "tag=$(git rev-parse HEAD)" > $GITHUB_OUTPUT - - - name: Print tag - run: echo "Running dev build for ${{ steps.extract_tag.outputs.tag }}" - - - name: Login to Open Source ECR - run: | - USERNAME=$(powershell.exe "echo \$Env:UserName") - # remove wincred entry and fix json format by replacing }, with } - cat "C:\\Users\\${USERNAME}\\.docker\\config.json" | grep -v "wincred" | sed 's/},$/}/' > "C:\\Users\\${USERNAME}\\.docker\\config.json.tmp" - mv "C:\\Users\\${USERNAME}\\.docker\\config.json.tmp" "C:\\Users\\${USERNAME}\\.docker\\config.json" - make login - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }} - - - name: Download binary action artifact from build phase - uses: actions/download-artifact@v4 - with: - name: otelcol-sumo-${{matrix.arch_os}}.exe - path: artifacts/ - - - name: Build and push image to Open Source ECR - run: | - cp artifacts/otelcol-sumo-${{matrix.arch_os}}.exe otelcol-sumo.exe - make build-push-container-windows \ - BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \ - PLATFORM=${{ matrix.arch_os }}_${{ matrix.base_image_tag }} - push-docker-manifest: name: Push joint container manifest runs-on: ubuntu-20.04 @@ -439,7 +393,6 @@ jobs: # when darwin build fails. - build-darwin - build-container-images - - build-windows-container-images steps: - uses: actions/checkout@v4 @@ -484,7 +437,7 @@ jobs: run: | make push-container-manifest \ BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \ - PLATFORMS="linux/amd64 linux/arm64 windows/amd64/ltsc2022 windows/amd64/ltsc2019" + PLATFORMS="linux/amd64 linux/arm64" - name: Push joint UBI-based container manifest for all platforms to Open Source ECR run: | From d8ba249bd77809d29560dd1da941d0dd6577dad3 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Thu, 29 Feb 2024 14:41:36 +0100 Subject: [PATCH 19/22] chore: unify dev and pr builds Signed-off-by: Dominik Rosiek --- .github/workflows/dev_builds.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml index 41e8dc601e..6790c96339 100644 --- a/.github/workflows/dev_builds.yml +++ b/.github/workflows/dev_builds.yml @@ -194,7 +194,7 @@ jobs: build-windows-container-images: name: Build Windows container - runs-on: windows-2022 + runs-on: ${{ matrix.runs_on }} needs: - build strategy: @@ -202,8 +202,10 @@ jobs: include: - arch_os: windows_amd64 base_image_tag: ltsc2022 + runs-on: windows-2022 - arch_os: windows_amd64 base_image_tag: ltsc2019 + runs-on: windows-2019 steps: - uses: actions/checkout@v4 From ca0481e84f6b845c6ddaccd8dd8730bfc1b05964 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Thu, 29 Feb 2024 15:07:30 +0100 Subject: [PATCH 20/22] chore: fix syntax Signed-off-by: Dominik Rosiek --- .github/workflows/dev_builds.yml | 2 +- .github/workflows/pull_requests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml index 6790c96339..82aab71e3b 100644 --- a/.github/workflows/dev_builds.yml +++ b/.github/workflows/dev_builds.yml @@ -194,7 +194,7 @@ jobs: build-windows-container-images: name: Build Windows container - runs-on: ${{ matrix.runs_on }} + runs-on: ${{ matrix.runs-on }} needs: - build strategy: diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index c2dadde947..850006a92f 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -364,7 +364,7 @@ jobs: name: Build windows container needs: - build - runs-on: ${{ matrix.runs_on }} + runs-on: ${{ matrix.runs-on }} strategy: matrix: include: From c886a1b7d7a45b7c6dd33bf2a70bf9ddcb1ee2ea Mon Sep 17 00:00:00 2001 From: Dominik Rosiek <58699848+sumo-drosiek@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:38:25 +0100 Subject: [PATCH 21/22] Update .github/workflows/dev_builds.yml --- .github/workflows/dev_builds.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml index 82aab71e3b..805b955165 100644 --- a/.github/workflows/dev_builds.yml +++ b/.github/workflows/dev_builds.yml @@ -5,7 +5,6 @@ on: branches: - main - 'dev-build/*' - - drosiek-windows-container defaults: run: From c6122e967e474fd74585792bd22d95d9d2ff7ec6 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek <58699848+sumo-drosiek@users.noreply.github.com> Date: Fri, 1 Mar 2024 11:07:32 +0100 Subject: [PATCH 22/22] Update ci/build-push-multiplatform.sh --- ci/build-push-multiplatform.sh | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/ci/build-push-multiplatform.sh b/ci/build-push-multiplatform.sh index 8fac78389e..39b59a15a2 100755 --- a/ci/build-push-multiplatform.sh +++ b/ci/build-push-multiplatform.sh @@ -2,16 +2,7 @@ set -eo pipefail -if echo "${PLATFORM}" | grep windows; then - while ! docker images; do - echo "Cannot connect to docker daemon" - sleep 1 - done -else - while ! docker buildx ls; do - echo "Cannot connect to docker daemon" - sleep 1 - done +if echo "${PLATFORM}" | grep -v windows; then DOCKER_BUILDX_LS_OUT=$(docker buildx ls <<-END END