Skip to content

feat(docker/v2): initial implementation#5793

Merged
caarlos0 merged 33 commits intomainfrom
docker-v2
Aug 21, 2025
Merged

feat(docker/v2): initial implementation#5793
caarlos0 merged 33 commits intomainfrom
docker-v2

Conversation

@caarlos0
Copy link
Copy Markdown
Member

@caarlos0 caarlos0 commented May 26, 2025

This is the v2 of the docker feature!

  • better DX (less yaml repetition and templates)
  • simpler implementation

So now, what happens:

  • if --snapshot, it'll build the manifest, but not push it (only useful to test the actual docker image build, not the image itself)
  • otherwise, on publish, it'll run a single docker buildx build to build and publish the manifest + SBOM
  • docker_signs should still work
  • docker_digests should still work

Discussion for after the merge: https://github.com/orgs/goreleaser/discussions/6005

TODO from the top of my head:


closes #5733

Footnotes

  1. Not really needed, will only run in publish, which runs in the merging step.

@caarlos0 caarlos0 self-assigned this May 26, 2025
@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 26, 2025
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 27, 2025

Deploying goreleaser with  Cloudflare Pages  Cloudflare Pages

Latest commit: ddae597
Status: ✅  Deploy successful!
Preview URL: https://4faac312.goreleaser.pages.dev
Branch Preview URL: https://docker-v2.goreleaser.pages.dev

View logs

@pull-request-size pull-request-size Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 27, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2025

Codecov Report

❌ Patch coverage is 81.34111% with 64 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@c5158b4). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/pipe/docker/v2/docker.go 77.85% 50 Missing and 14 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5793   +/-   ##
=======================================
  Coverage        ?   82.75%           
=======================================
  Files           ?      167           
  Lines           ?    16932           
  Branches        ?        0           
=======================================
  Hits            ?    14012           
  Misses          ?     2314           
  Partials        ?      606           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@polarathene

This comment was marked as outdated.

@polarathene

This comment was marked as outdated.

@polarathene

This comment was marked as outdated.

@caarlos0

This comment was marked as outdated.

@caarlos0

This comment was marked as outdated.

@polarathene

This comment was marked as outdated.

@caarlos0

This comment was marked as outdated.

@polarathene

This comment was marked as outdated.

caarlos0 added 2 commits June 7, 2025 11:34
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@EpicStep

This comment was marked as outdated.

@caarlos0 caarlos0 marked this pull request as draft July 25, 2025 02:02
@caarlos0

This comment was marked as outdated.

@jkroepke

This comment was marked as outdated.

@caarlos0

This comment was marked as outdated.

@caarlos0

This comment was marked as outdated.

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Comment thread .goreleaser.yaml
Comment thread pkg/config/config.go
}

// DockerV2 is the new Docker build pipe options.
type DockerV2 struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not exposing build_flag_templates ?

Use-cases are --build-context, --cache-from, --cache-to, --no-cache.

Not sure if it worth to expose each single CLI options. Something like extra_args for advanced usage would be great.

Copy link
Copy Markdown
Member Author

@caarlos0 caarlos0 Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think we can add the flags yes

will probably do in a subsequent PR


## Setting up a builder

For buildx to work, you'll need to have a builder that supports multi-platform
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note sure, if you would like to mention

https://github.com/docker/setup-buildx-action

for GHA as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! We should probably have a complete actions example

Comment thread www/docs/customization/dockers_v2.md
Comment thread www/docs/deprecations.md
Comment on lines +171 to +172
Feel free to suggest improvements
[here](https://github.com/orgs/goreleaser/discussions/6005).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about having a push option, which has the value push: {{ not .IsSnapshot }} by default. If an end-user really wants to have usage images from a snapshot build, he can opt-in. He also can use templated image_templates to configure different push location.

My use case here: I'm running --snapshot on main branches and I would like to push the main branch to the main tag. Thats one way, how I can quickly get feedback from reporters without publish a full release.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the use case for nightly builds... if we allow to pass random flags, though, you could still pass a {{ if .IsSnapshot }}--push{{ end }} then 🤔


The build context itself is a temporary directory which contains the binaries
and packages for the target platforms, which you can `COPY` into your image
(mind the use of `$TARGETPLATFORM` above).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Idea!

@caarlos0 caarlos0 changed the title feat(docker): dockers_v2 feat(docker/v2): initial implementation Aug 21, 2025
caarlos0 added a commit that referenced this pull request Aug 21, 2025
needs #5793

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0 caarlos0 merged commit 102762f into main Aug 21, 2025
17 of 18 checks passed
@caarlos0 caarlos0 deleted the docker-v2 branch August 21, 2025 20:28
caarlos0 added a commit that referenced this pull request Aug 21, 2025
needs #5793

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
caarlos0 added a commit that referenced this pull request Aug 22, 2025
needs #5793

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
caarlos0 added a commit that referenced this pull request Aug 22, 2025
needs #5793

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@ryancurrah
Copy link
Copy Markdown
Contributor

we will now run a single docker buildx build with the given platforms, which will build and publish the manifest and SBOM.

For teams that only use Go Releaser to build artifacts (and not to publish them), will this switch to docker buildx build + manifest publishing break our workflow?

This is how we currently build artifacts.

goreleaser release --clean --skip=validate,publish

@caarlos0
Copy link
Copy Markdown
Member Author

Hmmm this might need some extra work - can you open an issue for this particular case?

If you run with --snapshot it will create the local images btw, but with skip publish it won't

@ryancurrah
Copy link
Copy Markdown
Contributor

We will look at an internal project to modify our 1000+ Go Releaser files to also publish. So I will hold off on the ticket for now. Thanks for the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New dockers configuration section

6 participants