Skip to content

Commit 3de9bdb

Browse files
authored
Merge pull request #322 from andyzhangx/windows-image-build
chore: refactor Windows image build and add test
2 parents ec9b26b + af10d5f commit 3de9bdb

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Go
1+
name: Linux Unit Test
22

33
on:
44
push:

Makefile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ GOVERSION ?= 1.17
2121
LINUX_ARCH ?= amd64
2222
WINDOWS_DISTROS ?=
2323

24-
WINDOWS_BASE_IMAGES=$(addprefix mcr.microsoft.com/windows/nanoserver:,$(WINDOWS_DISTROS))
25-
2624
DOCKER=DOCKER_CLI_EXPERIMENTAL=enabled docker
2725
STAGINGVERSION=${VERSION}
2826
STAGINGIMAGE=${REGISTRY}/local-volume-provisioner
@@ -35,11 +33,6 @@ _pos = $(if $(findstring $1,$2),$(call _pos,$1,\
3533
$(wordlist 2,$(words $2),$2),x $3),$3)
3634
pos = $(words $(call _pos,$1,$2))
3735

38-
# $(call lookup,wanted,list1,list2)
39-
# finds the index of `wanted` in list1, then, it returns the element of `list2`
40-
# at that index
41-
lookup = $(word $(call pos,$1,$2),$3)
42-
4336
all: build-container-linux-amd64
4437
.PHONY: all
4538

@@ -69,6 +62,12 @@ build-container-linux-%:
6962
--build-arg OS=linux \
7063
--build-arg ARCH=$* .
7164

65+
build-container-windows-%:
66+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -a -ldflags='-extldflags="-static" -X="main.version=${STAGINGVERSION}"' -mod vendor -o _output/windows/amd64/local-volume-provisioner.exe ./cmd/local-volume-provisioner
67+
$(DOCKER) buildx build --file=./deployment/docker/Dockerfile.Windows --platform=windows/amd64 \
68+
-t $(STAGINGIMAGE):$(STAGINGVERSION)_windows_$* --output=type=$(OUTPUT_TYPE) \
69+
--build-arg OSVERSION=$* .
70+
7271
build-and-push-container-linux-%: init-buildx
7372
CGO_ENABLED=0 GOOS=linux GOARCH=$* go build -a -ldflags '-extldflags "-static"' -mod vendor -o _output/linux/$*/local-volume-provisioner ./cmd/local-volume-provisioner
7473
$(DOCKER) buildx build --file=./deployment/docker/Dockerfile --platform=linux/$* \
@@ -81,7 +80,7 @@ build-and-push-container-windows-%: init-buildx
8180
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -a -ldflags='-extldflags="-static" -X="main.version=${STAGINGVERSION}"' -mod vendor -o _output/windows/amd64/local-volume-provisioner.exe ./cmd/local-volume-provisioner
8281
$(DOCKER) buildx build --file=./deployment/docker/Dockerfile.Windows --platform=windows/amd64 \
8382
-t $(STAGINGIMAGE):$(STAGINGVERSION)_windows_$* \
84-
--build-arg BASE_IMAGE=$(call lookup,$*,$(WINDOWS_DISTROS),$(WINDOWS_BASE_IMAGES)) \
83+
--build-arg OSVERSION=$* \
8584
--push .
8685

8786
test: build-container-linux-amd64

deployment/docker/Dockerfile.Windows

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
ARG BASE_IMAGE
15-
FROM ${BASE_IMAGE}
14+
ARG OSVERSION
15+
FROM mcr.microsoft.com/windows/nanoserver:${OSVERSION}
1616
LABEL description="Local Volume Provisioner"
1717

1818
ARG OS=windows

0 commit comments

Comments
 (0)