Skip to content

Commit

Permalink
chore: build multiple windows images
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Rosiek <[email protected]>
  • Loading branch information
Dominik Rosiek committed Feb 29, 2024
1 parent 5c6b91c commit 59e08f6
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/dev_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile_windows
Original file line number Diff line number Diff line change
@@ -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

Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
26 changes: 24 additions & 2 deletions ci/build-push-multiplatform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/[email protected]/gssapi_kerberos.go:62:10: constant 4294967295 overflows int
# ref: https://github.com/SumoLogic/sumologic-otel-collector/runs/2805247906
Expand All @@ -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
Expand All @@ -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}" \
Expand All @@ -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}" \
Expand All @@ -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}" \
Expand All @@ -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 \
Expand Down
11 changes: 9 additions & 2 deletions ci/push_docker_multiplatform_manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,24 @@ 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}"
exit 1
;;
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:"
Expand Down

0 comments on commit 59e08f6

Please sign in to comment.