Skip to content

Commit

Permalink
Update base image to ghcr.io/distroless/static:latest (ko-build#737)
Browse files Browse the repository at this point in the history
* Update base image to ghcr.io/distroless/static:latest

* Add more logging to e2e for windows

* skip timezone conversion on Windows
  • Loading branch information
imjasonh authored Jun 30, 2022
1 parent 79a463d commit a61e14d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
# Build and run the test/ binary, which should log "Hello there" served from KO_DATA_PATH
testimg=$(go run ./ build ./test --platform=${PLATFORM} --preserve-import-paths)
docker run ${testimg} --wait=false 2>&1 | grep "Hello there"
docker run ${testimg} --wait=false 2>&1 | tee >(grep "Hello there") # Log all output too.
# Check that symlinks in kodata are chased.
# Skip this test on Windows.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/options/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

const (
// configDefaultBaseImage is the default base image if not specified in .ko.yaml.
configDefaultBaseImage = "gcr.io/distroless/static:nonroot"
configDefaultBaseImage = "ghcr.io/distroless/static:latest"
)

// BuildOptions represents options for the ko builder.
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/options/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestDefaultBaseImage(t *testing.T) {
t.Fatal(err)
}

wantDefaultBaseImage := "gcr.io/distroless/base:nonroot" // matches value in ./testdata/.ko.yaml
wantDefaultBaseImage := "alpine" // matches value in ./testdata/config/.ko.yaml
if bo.BaseImage != wantDefaultBaseImage {
t.Fatalf("wanted BaseImage %s, got %s", wantDefaultBaseImage, bo.BaseImage)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/options/testdata/config/.ko.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
defaultBaseImage: gcr.io/distroless/base:nonroot
defaultBaseImage: alpine
21 changes: 21 additions & 0 deletions test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ package main

import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/signal"
"path/filepath"
"runtime"
"syscall"
"time"

// Give this an interesting import
_ "github.com/google/go-containerregistry/pkg/registry"
Expand All @@ -40,6 +43,24 @@ func main() {

log.Println("version =", version)

if runtime.GOOS == "windows" {
// Go seems to not load location data from Windows, so timezone
// conversion fails unless tzdata is embedded in the Go program
// with the go build tag `timetzdata`. Since we want to test
// loading tzdata provided by the base image below, we'll just
// skip that for Windows here.
// See https://github.com/google/ko/issues/739
log.Println("skipping timezone conversion on Windows")
} else {
// Exercise timezone conversions, which demonstrates tzdata is provided
// by the base image.
now := time.Now()
loc, _ := time.LoadLocation("UTC")
fmt.Printf("UTC Time: %s\n", now.In(loc))
loc, _ = time.LoadLocation("America/New_York")
fmt.Printf("New York Time: %s\n", now.In(loc))
}

dp := os.Getenv("KO_DATA_PATH")
file := filepath.Join(dp, *f)
bytes, err := ioutil.ReadFile(file)
Expand Down

0 comments on commit a61e14d

Please sign in to comment.