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 f89177d
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 27 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/dev_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
19 changes: 6 additions & 13 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,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

Expand Down Expand Up @@ -397,21 +401,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"
10 changes: 7 additions & 3 deletions .github/workflows/release_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: |
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_IMAGE_TAG=ltsc2022
FROM mcr.microsoft.com/windows/servercore:${BASE_IMAGE_TAG}
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_IMAGE_TAG ?= ""

DOCKERFILE = Dockerfile

Expand Down Expand Up @@ -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
Expand Down
29 changes: 27 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_IMAGE_TAG}" ]]; then
BASE_IMAGE_TAG="-${BASE_IMAGE_TAG}"
fi

if [[ -z "${PLATFORM}" ]]; then
echo "No PLATFORM passed in"
exit 1
Expand All @@ -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
Expand All @@ -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"
;;

Expand All @@ -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
Expand All @@ -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}" \
Expand All @@ -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}" \
Expand All @@ -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}" \
Expand All @@ -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 \
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_IMAGE_TAG_SUFFIX="-ltsc2022"
;;

"windows/amd64/ltsc2019")
BUILD_ARCH="amd64"
BUILD_PLATFORM="windows"
BASE_IMAGE_TAG_SUFFIX="-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_IMAGE_TAG_SUFFIX}")
done

echo "Tags in the manifest:"
Expand Down

0 comments on commit f89177d

Please sign in to comment.