Ko has different build flags to change the docker image repo path: https://ko.build/reference/ko_build/
We have an example repo with dir cmd/hello-k8s/main.go
.
Realized options and results are already described in https://ko.build/configuration/#naming-images
- no flags
KO_DOCKER_REPO=ghcr.io/samlaf ko build cmd/hello-k8s/main.go
Creates
- --bare this will only work if repo name is an actual repo
KO_DOCKER_REPO=ghcr.io/samlaf/hello-k8s ko build --bare cmd/hello-k8s/main.go
- --base-import-paths
KO_DOCKER_REPO=ghcr.io/samlaf ko build --base-import-paths cmd/hello-k8s/main.go
- --preserve-import-paths
KO_DOCKER_REPO=ghcr.io/samlaf ko build --preserve-import-paths cmd/hello-k8s/main.go