From caee5a05fe748867c06cf7adccc9514a5a3711d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 22 Jul 2024 15:21:05 +0200 Subject: [PATCH] Add hostprocess image builds (#1507) --- .github/workflows/release.yml | 25 +++++++++++++++++++++++++ Makefile | 14 ++++++++++++-- README.md | 6 ++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9bf3136d1..c1df3ffef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,6 +31,31 @@ jobs: with: go-version-file: 'go.mod' + # https://github.com/pl4nty/Windows-Containers/blob/Main/helpful_tools/Install-BuildKit-GitHubActions/workflow.yaml + - name: Setup containerd + run: | + $version = "1.7.17" + curl.exe -L https://github.com/containerd/containerd/releases/download/v$version/containerd-$version-windows-amd64.tar.gz -o containerd.tar.gz + tar.exe xvf containerd.tar.gz + .\bin\containerd.exe --register-service + Start-Service containerd + - name: Setup BuildKit + run: | + $version = "v0.13.2" + curl.exe -L https://github.com/moby/buildkit/releases/download/$version/buildkit-$version.windows-amd64.tar.gz -o buildkit.tar.gz + tar.exe xvf buildkit.tar.gz + + .\bin\buildkitd.exe --register-service + Start-Service buildkitd + - name: Setup Docker Buildx + run: | + $version = "v0.14.1" + curl.exe -L https://github.com/docker/buildx/releases/download/$version/buildx-$version.windows-amd64.exe -o $env:ProgramData\Docker\cli-plugins\docker-buildx.exe + - uses: docker/setup-buildx-action@v3 + with: + driver: remote + endpoint: npipe:////./pipe/buildkitd + - name: Install WiX run: dotnet tool install --global wix diff --git a/Makefile b/Makefile index dd1fa1d5e..7ab9e875e 100644 --- a/Makefile +++ b/Makefile @@ -58,10 +58,13 @@ package: crossbuild build-image: crossbuild $(DOCKER) build --build-arg=BASE=$(BASE_IMAGE):$(OS) -f Dockerfile -t local/$(DOCKER_IMAGE_NAME):$(VERSION)-$(OS) . +build-hostprocess: + $(DOCKER) buildx build --build-arg=BASE=mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0 -f Dockerfile -t local/$(DOCKER_IMAGE_NAME):$(VERSION)-hostprocess . + sub-build-%: $(MAKE) OS=$* build-image -build-all: $(addprefix sub-build-,$(ALL_OS)) +build-all: $(addprefix sub-build-,$(ALL_OS)) build-hostprocess push: set -x; \ @@ -76,9 +79,16 @@ push: $(DOCKER) manifest push --purge $${docker_repo}/$(DOCKER_IMAGE_NAME):$(VERSION); \ done +# We can't load the image into the local docker store, so we have to build and push it in one go +push-hostprocess: + set -x; \ + for docker_repo in ${DOCKER_REPO}; do \ + $(DOCKER) buildx build --push --build-arg=BASE=mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0 -f Dockerfile -t $${docker_repo}/$(DOCKER_IMAGE_NAME):$(VERSION)-hostprocess . + done + .PHONY: push-all push-all: build-all - $(MAKE) DOCKER_REPO="$(ALL_DOCKER_REPOS)" push + $(MAKE) DOCKER_REPO="$(ALL_DOCKER_REPOS)" push push-hostprocess # Mandatory target for container description sync action .PHONY: docker-repo-name diff --git a/README.md b/README.md index ce0f9ead6..4a788aebf 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,12 @@ The windows_exporter can be run as a Docker container. The Docker image is avail * [GitHub Container Registry](https://github.com/prometheus-community/windows_exporter/pkgs/container/windows-exporter): `ghcr.io/prometheus-community/windows-exporter` +### Tags + +The Docker image is tagged with the version of the exporter. The `latest` tag is also available and points to the latest release. + +Additionally, a flavor `hostprocess` with `-hostprocess` as suffix is based on the https://github.com/microsoft/windows-host-process-containers-base-image +which is designed to run as a Windows host process container. The size of that images is smaller than the default one. ## Kubernetes Implementation