Skip to content

Commit 9524d03

Browse files
committed
Provide configurable options for variable to build windows image
1 parent b88ac44 commit 9524d03

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

hack/release.sh

+9-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ BUILD_RELEASE_TYPE="${BUILD_RELEASE_TYPE:-}"
5252
GOLANG_IMAGE=${CUSTOM_REPO_FOR_GOLANG:-}golang:1.22
5353

5454
ARCH=amd64
55-
OSVERSION=1809
55+
OSVERSION=${OSVERSION:=1809}
5656
# OS Version for the Windows images: 1809, 20H2, ltsc2022
5757
OSVERSION_WIN=(1809 20H2 ltsc2022)
5858
# The output type could either be docker (local), or registry.
@@ -62,6 +62,9 @@ LINUX_IMAGE_OUTPUT="type=docker"
6262

6363
REGISTRY=
6464

65+
# set windows buildkit image if not given already
66+
WIN_BUILDKIT_IMAGE="${WIN_BUILDKIT_IMAGE:=moby/buildkit:v0.10.6}"
67+
6568
# set base image if not given already
6669
BASE_IMAGE="${BASE_IMAGE:=photon:4.0}"
6770

@@ -108,7 +111,7 @@ function fatal() {
108111

109112

110113
function build_driver_images_windows() {
111-
docker buildx use vsphere-csi-builder-win || docker buildx create --driver-opt image=moby/buildkit:v0.10.6 --name vsphere-csi-builder-win --platform windows/amd64 --use
114+
docker buildx use vsphere-csi-builder-win || docker buildx create --driver-opt image=${WIN_BUILDKIT_IMAGE} --name vsphere-csi-builder-win --platform windows/amd64 --use
112115
echo "building ${CSI_IMAGE_NAME}:${VERSION} for windows"
113116
# some registry do not allow uppercase tags
114117
osv=$(lcase "${OSVERSION}")
@@ -169,13 +172,13 @@ function build_images() {
169172
LATEST="latest"
170173

171174
# build images for linux platform
172-
build_driver_images_linux
173-
build_syncer_image_linux
175+
#build_driver_images_linux
176+
#build_syncer_image_linux
174177

175-
if [ "$DO_WINDOWS_BUILD" = true ]; then
178+
#if [ "$DO_WINDOWS_BUILD" = true ]; then
176179
# build images for windows platform
177180
build_driver_images_windows
178-
fi
181+
#fi
179182
}
180183

181184
function push_manifest_driver() {

images/windows/driver/Dockerfile

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
################################################################################
1818
# This build arg allows the specification of a custom Golang image.
1919
ARG GOLANG_IMAGE=golang:1.22
20-
ARG OSVERSION
20+
ARG OSVERSION=${OSVERSION:-1809}
2121
ARG ARCH=amd64
22+
ARG TARGET_PLATFORM=linux/amd64
2223

2324
################################################################################
2425
## BUILD STAGE ##
2526
################################################################################
2627
# Build the manager as a statically compiled binary so it has no dependencies
2728
# libc, muscl, etc.
28-
FROM --platform=linux/amd64 ${GOLANG_IMAGE} as builder
29+
FROM --platform=${TARGET_PLATFORM} ${GOLANG_IMAGE} AS builder
2930

3031
# This build arg is the version to embed in the CSI binary
3132
ARG VERSION=unknown
@@ -38,14 +39,14 @@ COPY go.mod go.sum ./
3839
COPY pkg/ pkg/
3940
COPY cmd/ cmd/
4041
ENV CGO_ENABLED=0
41-
ENV GOPROXY ${GOPROXY:-https://proxy.golang.org}
42+
ENV GOPROXY=${GOPROXY:-https://proxy.golang.org}
4243
RUN GOOS=windows GOARCH=amd64 go build -a -ldflags="-w -s -extldflags=static -X sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service.Version=${VERSION}" -o ./bin/vsphere-csi.windows_amd64 cmd/vsphere-csi/main.go
4344

4445

4546
################################################################################
4647
## MAIN STAGE ##
4748
################################################################################
48-
FROM --platform=linux/amd64 gcr.io/k8s-staging-e2e-test-images/windows-servercore-cache:1.0-linux-${ARCH}-${OSVERSION} as core
49+
FROM --platform=${TARGET_PLATFORM} gcr.io/k8s-staging-e2e-test-images/windows-servercore-cache:1.0-linux-${ARCH}-${OSVERSION} AS core
4950

5051
FROM mcr.microsoft.com/windows/nanoserver:${OSVERSION}
5152
COPY --from=core /Windows/System32/netapi32.dll /Windows/System32/netapi32.dll

0 commit comments

Comments
 (0)