From 96bedf16df480807ab04865db85a0b3c1eb2f470 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Tue, 14 Dec 2021 12:56:21 -0500 Subject: [PATCH] Add .ko.yaml to base ko container image on golang:1.17 (#533) * Add .ko.yaml to base ko container image on golang:1.17 Ignore this in e2e tests, since even though golang:1.17 provides a Windows base image, ko's base image platform selection doesn't take osversion into account. The e2e tests don't exercise golang usage at all, so it shouldn't matter. * Update README --- .github/workflows/e2e.yaml | 3 +++ .ko.yaml | 2 ++ README.md | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .ko.yaml diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 82d42f62be..a6b4f592cf 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -33,6 +33,9 @@ jobs: eval $(go env | sed -r 's/^(set )?(\w+)=("?)(.*)\3$/\2="\4"/gm') if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then + # Always use the nanoserver base image, which matches the Windows + # version used by the GitHub Actions Windows runner. + rm .ko.yaml export KO_DEFAULTBASEIMAGE=mcr.microsoft.com/windows/nanoserver:1809 fi diff --git a/.ko.yaml b/.ko.yaml new file mode 100644 index 0000000000..6371051bce --- /dev/null +++ b/.ko.yaml @@ -0,0 +1,2 @@ +baseImageOverrides: + github.com/google/ko: golang:1.17 diff --git a/README.md b/README.md index 614fd074f0..e0e81227c5 100644 --- a/README.md +++ b/README.md @@ -466,9 +466,11 @@ You can try out building a Windows container image by [setting the base image](# For example, to build a Windows container image for `ko`, from within this repo: ``` -KO_DEFAULTBASEIMAGE=mcr.microsoft.com/windows/nanoserver:1809 ko publish ./ --platform=windows/amd64 +ko publish ./ --platform=windows/amd64 ``` +This works because the `ko` image is configured in [`.ko.yaml`](./.ko.yaml) to be based on a `golang` base image, which provides platform-specific images for both Linux and Windows. + ### Known issues 🐛 - Symlinks in `kodata` are ignored when building Windows images; only regular files and directories will be included in the Windows image.