Live data from Hacker News

Ko: Easy Go Containers

ko.build

11–20 of 41 posts

Re: Ko: Easy Go Containers

#11
post #2

I have used something like this in the past: FROM alpine:latest AS base # Scratch does not have shell so we have to create non-root user in here and later copy it into scratch. RUN adduser -D -u 123456 appusr FROM scratch # Copy the binary. COPY foo.bin /foo.bin # Copy the user and set is as active. COPY --from=base /etc/passwd /etc/passwd USER appusr # Non-root user cannot bind to "privileged" ports( Simple. But i c…

> i can see ko being good alternative if you for some reason do not want to install docker on your computer The already established good alternative to Docker desktop is Rancher Desktop[1]. [1] https://rancherdesktop.io/

Sadly, Rancher Desktop still uses Docker, right?

Re: Ko: Easy Go Containers

#13
post #5

I love `ko`. I wish there was something similar for rust but I haven't found it quite yet

I have a very opinionated library that builds Docker images in pure Rust.

I don't think building something like `ko` with it should be that much work. (I know, famous last words)

I'll have to check with $employer if it's ok to open source it.

Re: Ko: Easy Go Containers

#14
post #9
post #2

I have used something like this in the past: FROM alpine:latest AS base # Scratch does not have shell so we have to create non-root user in here and later copy it into scratch. RUN adduser -D -u 123456 appusr FROM scratch # Copy the binary. COPY foo.bin /foo.bin # Copy the user and set is as active. COPY --from=base /etc/passwd /etc/passwd USER appusr # Non-root user cannot bind to "privileged" ports( Simple. But i c…

I thought that go doesn't work in Alpine because of shared libs?

Build with `CGO_ENABLED=0`, perhaps?

Re: Ko: Easy Go Containers

#15
post #2

I have used something like this in the past: FROM alpine:latest AS base # Scratch does not have shell so we have to create non-root user in here and later copy it into scratch. RUN adduser -D -u 123456 appusr FROM scratch # Copy the binary. COPY foo.bin /foo.bin # Copy the user and set is as active. COPY --from=base /etc/passwd /etc/passwd USER appusr # Non-root user cannot bind to "privileged" ports( Simple. But i c…

That works, but it also means maintaining a Dockerfile that does the COPYs, when all you're really doing is assembling image layers. This is more or less exactly what ko does, without using the Dockerfile language to describe it.

Not having to run a Docker daemon is just a nice bonus! :)

Re: Ko: Easy Go Containers

#16
Hey, ko maintainer here! I'd love to answer any questions or hear any feedback folks have.

Ko's simplicity comes from focusing on doing exactly one thing well -- it doesn't have to run containers to build code in any language, it just builds minimal Go containers, and that means it can focus on doing that as well as possible.

Another powerful benefit of focusing on Go (IMO) is that ko can be used to transform a Go importpath to a built image reference.

A common simple use: `docker run $(ko build ./cmd/app)`

This is also how Kubernetes YAML templating[1] works, and it's also how the Terraform provider[2] works -- you give it an importpath, and ko transforms it into a built image reference you can pass to the rest of your config. I don't even "use ko" day-to-day most days, I mostly just use terraform. :)

1: https://ko.build/features/k8s/ 2: https://ko.build/advanced/terraform/

Re: Ko: Easy Go Containers

#19

Hey, ko maintainer here! I'd love to answer any questions or hear any feedback folks have. Ko's simplicity comes from focusing on doing exactly one thing well -- it doesn't have to run containers to build code in any language, it just builds minimal Go containers, and that means it can focus on doing that as well as possible. Another powerful benefit of focusing on Go (IMO) is that ko can be used to transform a Go im…

Hello Jason!

Re: Ko: Easy Go Containers

#20
Dammit, why didn't I know about this? In general, I always have the feeling I'm not aware of great applications out there, and I confirm this sensation every time I find them, like now!

How do you all stay tune of the great apps out there?

Post reply on HN