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
add ko support for building and pushing container images #2564
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the PR!
made some comments here.
would also be nice to add tests for this 🙏
btw, with this we can also easily create multi-arch docker images, just need to pass |
thinking more about this, I got more questions:
everything would likely work for "simple" projects, but not sure about more complex ones... |
I completed all the comments, here is the result when I tried this integration with my own CLI and it uses the following $ export GITHUB_TOKEN=xxx
$ export KO_DOCKER_REPO=docker.io/devopps
$ goreleaser release --rm-dist
$ crane ls devopps/hello-world-cli
0.3.3
latest
v0 .goreleaser# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
ldflags:
- -s -w -X github.com/GoTurkiye/hello-world-cli/cmd.GitCommit={{ .Commit }} -X github.com/GoTurkiye/hello-world-cli/cmd.Version={{ .Version }}
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
dockers:
- image_templates:
- "{{ .ProjectName }}"
- "{{ .ProjectName }}:{{ .Tag }}"
- "{{ .ProjectName }}:v{{ .Major }}"
goos: linux
goarch: amd64
use: ko |
@imjasonh maybe can help us here. |
Sorry for the delayed response. I'm a bit worried that For the question of "how to configure wdyt? |
thank you for such a great explanation, I think both methods (current solution and your suggestion) would work fine but yes I agree with your concerns about configuring ko while using it in GoReleaser because ko also builds the binary first which means that fields defined in 👀 https://github.com/google/ko#overriding-go-build-settings WDYT @caarlos0? |
I'm thinking maybe we could instead use ko as a dependency and skip the go build part (as we already do that), and just build the images... would that be possible (haven't investigate ko's codebase yet)? if so, wdyt? |
I'm not so sure whether instead of using the binary, and importing |
The main functions you'd probably care about are |
cc/ @cpanato |
closing for now, as we'll discuss this in our community meeting |
@caarlos0 tried searching briefly for docs around a community meeting and couldn't find anything -- have a link handy? |
sure, here you go: goreleaser/community#2 PS: we don't have a proper date yet, but likely later january or early february |
let's kick this off and rewrite it by using ko as a library instead of executing it directly through the binary. This repo will help us with that: https://github.com/imjasonh/miniko. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Signed-off-by: Batuhan Apaydin batuhan.apaydin@trendyol.com
Co-authored-by: Furkan furkan.turkal@trendyol.com (@Dentrax)
Co-authored-by: Erkan Zileli erkan.zileli@trendyol.com (@erkanzileli)
fix #2556
to add ko support for building and pushing container images
Sample .goreleaser.yml