Skip to content
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

Building with ko instead of docker breaks the released image when an existing database is used #913

Closed
ekeih opened this issue Jan 1, 2024 · 4 comments
Labels
bug Something isn't working as supposed to

Comments

@ekeih
Copy link
Contributor

ekeih commented Jan 1, 2024

Describe the bug

After upgrading to v3.22.1 the backend crashes with error during DB migration: attempt to write a readonly database. This happens because the backend is now running as user nonroot with uid and gid 65532 (or at least that is what I think based on the documentation, see below).

To Reproduce
Steps to reproduce the behavior:

  1. Update the backend to the v3.22.1 docker image.

Expected behavior
The backend should not crash and it should be able to write to existing sqlite databases.

Additional context

Switching to scratch with ko is not possible

Proposal

  • Running the backend as a non-root user is actually a good thing.
  • We could keep the new base image and "fail forward".
  • This would be (or already is) a breaking change because existing users would need to change the file system permissions of their sqlite database before upgrading.
  • The cgr.dev/chainguard/static image only has a latest tag, so future changes in the base image could cause issues in the future. Though, the image should be fairly minimal overall. An alternative could be to use another base image or create our own.
  • Depending on how long a decision/fix takes, we should consider reverting back to docker in the meantime.
@ekeih ekeih added the bug Something isn't working as supposed to label Jan 1, 2024
@morremeyer
Copy link
Member

Thanks for researching the issue this thoroughly!

With all this information, I agree with your proposal of failing forward. This decision is also made easier by the fact that the release of v4.0.0 is just days away, if at all.

However, I would also like to revert back to docker for now so that we have a clean upgrade path (upgrading the major will entail upgrading to the latest patch version of the major version before from v4.0.0 on).

Two questions:

  • What do you mean by The existing Docker image is not used by ko at all, it can be deleted when using ko., can we delete the Dockerfile.goreleaser with this?
  • Since cgr.dev/chainguard/static only has a latest tag, did you see a way to pin the digest of the image somewhere during your research?

@ekeih
Copy link
Contributor Author

ekeih commented Jan 1, 2024

However, I would also like to revert back to docker for now so that we have a clean upgrade path (upgrading the major will entail upgrading to the latest patch version of the major version before from v4.0.0 on).

Sounds like a good idea 👍

What do you mean by The existing Docker image is not used by ko at all, it can be deleted when using ko., can we delete the Dockerfile.goreleaser with this?

Ah sorry, I meant to write Dockerfile. Yes, we can delete Dockerfile.goreleaser when we switch to ko with v4. https://ko.build/advanced/migrating-from-dockerfile/ says You're done. You can delete your Dockerfile and uninstall docker. at the bottom.

Since cgr.dev/chainguard/static only has a latest tag, did you see a way to pin the digest of the image somewhere during your research?

I didn't see any documentation that this is possible. I also didn't see any saying it is not. But my gut feeling is that it is not possible.

@ekeih
Copy link
Contributor Author

ekeih commented Jan 1, 2024

ℹ️ I stopped my backend instance, ran chown 65532:65532 on the sqlite file and its parent directory, started the new backend version (v3.22.1) and everything worked.

@morremeyer
Copy link
Member

I added the change back with #915, check the upgrade docs for v4.0.0.

Thanks again for the research!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as supposed to
Projects
None yet
Development

No branches or pull requests

2 participants