Skip to content

feat: publish image to Docker Hub#1043

Merged
phm07 merged 7 commits into
mainfrom
publish-docker-image
May 9, 2025
Merged

feat: publish image to Docker Hub#1043
phm07 merged 7 commits into
mainfrom
publish-docker-image

Conversation

@phm07

@phm07 phm07 commented May 8, 2025

Copy link
Copy Markdown
Contributor

This PR adds CI to release OCI images to Docker Hub using ko.

@phm07 phm07 self-assigned this May 8, 2025
@phm07 phm07 requested a review from a team as a code owner May 8, 2025 15:10
@phm07

phm07 commented May 8, 2025

Copy link
Copy Markdown
Contributor Author

We might want to rename this to feat: if we want it to show up in the changelog

@codecov

codecov Bot commented May 8, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 70.36%. Comparing base (a6a63d8) to head (2523e90).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
internal/state/config/config.go 40.00% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1043      +/-   ##
==========================================
- Coverage   70.38%   70.36%   -0.02%     
==========================================
  Files         247      247              
  Lines       10867    10870       +3     
==========================================
  Hits         7649     7649              
- Misses       2543     2544       +1     
- Partials      675      677       +2     
Flag Coverage Δ
e2e 50.66% <0.00%> (-0.02%) ⬇️
unit 63.30% <40.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Comment thread .goreleaser.yml Outdated
Comment on lines 38 to 58

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we have a shell inside the container? E.g using a alpine or debian base image?

I think it would fit for this use case, where we might want to have a shell for the CLI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you think it justifies the bloat? You could also just run the command by itself and mount a config from the host

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just checked, the image would be ~26MB as is, using alpine as a base image would add another ~8MB.

@apricote apricote May 9, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If its just about a shell, a different ko base image can provide this: https://github.com/apricote/releaser-pleaser/blob/c31e40d04bc9acc7b152d630cbdf3a6b2be0aebf/.ko.yaml#L6

I would be curious to hear where the shell would be useful though. In my mind users would run this with an alias and use their own shell for all things.

alias hcloud="docker run --rm -it -v ~/.config/hcloud/config.toml:/config.toml hetznercloud/cli:v1.xx --"
hcloud server list | grep ...

@worr how do you intend to use this image?

@jooola jooola May 9, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For example in a GitLab CI job, one could reference the image and run their CI tasks by having a shell in the image. Or a shady/dangerous k8s init container.

I think it makes sens to have a shell just because it is a CLI. Being able to run inside the image should also be considered (not always outside).

No strong opinion though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think your examples make sense. Maybe we should base it on alpine. I checked out the chainguard/busybox image and it seems to be quite large at 24MB.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think ko can use any base image, not only chainguard ones. Happy to try with a base alpine/busybox image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But the fact that the image provides a basic shell should be documented. To make sure that we do not remove it in the future as an optimization :D

@worr

worr commented May 9, 2025 via email

Copy link
Copy Markdown

Comment thread .goreleaser.yml Outdated

@jooola jooola May 9, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How does that work if the user extract the binary to use outside the container? Do we want to support this?

Or mount / inside the container (similar to network_mode: host but for the fs)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree that extracting the binary from the image would be problematic.
However I think mounting the entire FS into the container would be a bad idea because:

  • $HOME will still resolve to /home/nonroot so the config would be located at /home/nonroot/.config/hcloud/cli.toml
  • We should scope the possible file access as small as possible for security reasons

Maybe there is a way to detect if the binary is running inside a container dynamically during runtime? Or could we set HCLOUD_CONFIG somehow?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do not think we need to support extracting the binary explicitly. I like that we try to make defaults nicer for container users here.

ko unfortunately does not allow adding env variables to the image, so no possibility to do it through HCLOUD_CONFIG with ko.

If a user really wants to extract this binary, they can still set HCLOUD_CONFIG on their end to change the default.

@apricote apricote changed the title ci: publish image to Docker Hub feat: publish image to Docker Hub May 9, 2025
@phm07 phm07 force-pushed the publish-docker-image branch from 4b46f77 to 8882519 Compare May 9, 2025 13:50
@phm07 phm07 merged commit 794e544 into main May 9, 2025
6 checks passed
@phm07 phm07 deleted the publish-docker-image branch May 9, 2025 15:37
phm07 pushed a commit that referenced this pull request May 9, 2025
<!-- section-start changelog -->
### Features

- **load-balancer**: allow specifying network on create (#1013)
- **context**: add unset commmand (#1017)
- publish image to Docker Hub (#1043)

### Bug Fixes

- allow getting resources with number as name
- some list flags are not correctly parsed (#987)
- **load-balancer**: allow certificate names in addition to IDs when
creating/updating (#1026)
- config option flags sometimes not parsed correctly (#1025)

<!-- section-end changelog -->

---

<details>
<summary><h4>PR by <a
href="https://github.com/apricote/releaser-pleaser">releaser-pleaser</a>
🤖</h4></summary>

If you want to modify the proposed release, add you overrides here. You
can learn more about the options in the docs.

## Release Notes

### Prefix / Start

This will be added to the start of the release notes.

```rp-prefix
```

### Suffix / End

This will be added to the end of the release notes.

```rp-suffix
```

</details>

Co-authored-by: releaser-pleaser <>
phm07 pushed a commit that referenced this pull request May 30, 2025
<!-- section-start changelog -->
### Features

- **load-balancer**: allow specifying network on create (#1013)
- **context**: add unset commmand (#1017)
- publish image to Docker Hub (#1043)

### Bug Fixes

- allow getting resources with number as name
- some list flags are not correctly parsed (#987)
- **load-balancer**: allow certificate names in addition to IDs when
creating/updating (#1026)
- config option flags sometimes not parsed correctly (#1025)

<!-- section-end changelog -->

---

<details>
<summary><h4>PR by <a
href="https://github.com/apricote/releaser-pleaser">releaser-pleaser</a>
🤖</h4></summary>

If you want to modify the proposed release, add you overrides here. You
can learn more about the options in the docs.

## Release Notes

### Prefix / Start

This will be added to the start of the release notes.

```rp-prefix
```

### Suffix / End

This will be added to the end of the release notes.

```rp-suffix
```

</details>

Co-authored-by: releaser-pleaser <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants