envelope-zero / backend

Serves the API and contains the application logic
Other
6 stars 3 forks source link

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

Closed ekeih closed 10 months ago

ekeih commented 10 months ago

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

morremeyer commented 10 months ago

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:

ekeih commented 10 months ago

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 commented 10 months ago

ℹ️ 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 commented 10 months ago

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

Thanks again for the research!