-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: cmd/go: build: add -container flag #26657
Comments
IIUC this is only for static binaries? BTW, have you looked into |
We mostly use static binaries. But is that necessary? I have not looked into |
For dynamic binaries you are likely to require a bunch of apt/dnf packages, and probably it is better to use Docker/BuildKit/img/Buildah/whatever? |
Is the purpose here to build Go binaries that are runnable on certain container environments, or to build the container image too? If you want the former, I presume that the already accepted #26492 will do the job. If you want the latter, I'd imagine that the solution would pull in lots of code into the Go tree. Why not have that as a build/release tool that wraps |
The go command and the go project cannot serve every possible need. Instead we aim to provide a good foundation and good building blocks for custom tooling. It should be very easy to write a go-to-docker given the current go command functionality. And maybe -static in #26492 will make it even easier. A docker container can be and is often a lot more than one binary. It makes much more sense for additional tools layered on top of the go command to build those containers. If more from the go command is needed, great, let us know details. But broader packaging issues like generating docker containers directly is far beyond the go command's scope. |
This is a proposal to add -container flag to go build.
We use Go to write our cloud native applications. Most of the time, we don't use the binary itself directly. Rather we turn that into a Docker image using alpine or busybox as the
From
image. This flag will allow Go developers to produce a Docker image for Go applications in most simple cases. The example command could look like this:go build -o mycompany/myapp:v1 -container busybox ./...
It is now possible to build Docker images (which are just tar files for most part) without needing any Docker daemon thanks to Buildkit and @jessfraz's img project.
cc: @AkihiroSuda
The text was updated successfully, but these errors were encountered: