lifeym/ko

By lifeym

Updated over 1 year ago

Latest ko-build image built from source.

Image

114

Why

Latest ko image built from source.

The original official ko-build/ko image is too slow to pull, docker hub is much faster:)

Or you can build a private one to enhance ci pipeline.

How to build

Build from source is easy.

First clone the source repo:

git clone https://github.com/ko-build/ko

And then run the following command:

KO_DOCKER_REPO=<YOUR REPO PATH> KO_DEFAULTBASEIMAGE=docker.io/library/golang:1.21-alpine ko build -B --platform=all

This also canbe done within a container to avoid clone sources to the host disk:

docker run --rm -v ko:/src bitnami/git:latest git clone https://github.com/ko-build/ko
docker run --rm -v ko:/src -v <PATH TO YOUR <docker config.json>>:/root/.docker -w /src golang:1.21-alpine sh -c "echo https://dl-cdn.alpinelinux.org/alpine/edge/testing/ >> /etc/apk/repositories \
    && apk update && apk add ko \
    && KO_DOCKER_REPO=<YOUR REPO PATH> KO_DEFAULTBASEIMAGE=docker.io/library/golang:1.21-alpine ko build -B --platform=all"
docker volume rm ko

How to do an auto login?

ko do login with a docker config.json. If you donot know how to get one, do the following:

docker run --rm -v $(pwd):/root/.docker lifeym/ko login -u <YOUR USERNAME> -p <YOUR PASSWORD> <YOUR REGISTRY URL>

Then you can mount this config.json to your ko image under path: /root/.docker

Docker Pull Command

docker pull lifeym/ko