What is the expected behavior for kan-migrate?
🐛 Bug Report
Describe the bug When deploying via the provided compose file kan-migrate fails with error code 1. This breaks deployment workflows via Portainer for example because the service is not healthy. Container log below. Is this an expected behaviour? Or should the service stay healthy?
No config path provided, using default 'drizzle.config.ts'
Reading config file '/db/drizzle.config.ts'
Using 'pg' driver for database querying
npm notice
npm notice New major version of npm available! 10.8.2 -> 11.12.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.12.1
npm notice To update run: npm install -g [email protected]
npm notice
[⣷] applying migrations...[⣷] applying migrations...
To Reproduce Steps to reproduce the behavior: Copy docker compose and run docker compose up 4. See error
Expected behavior IDK, its not documented?
Environment (please complete the following information):
- OS: Portainer on Linux
- Browser Chrome
- App version/commit latest
The kan-migration container only runs once when you restart the container stack, running the migrations if any new ones are present to the database, then it shuts down and doesn't run again. So basically when you do docker compose pull inside the directory with your docker-compose.yml, it gets all the fresh updated data, and you would then do something like: docker compose restart or docker compose down && docker compose up -d to get the containers restarted and updated. When the containers start, the kan-migrate runs, does migrations and just shuts down, that's it.
Having to run the migration in a separate container is not very self-hosted friendly. It would be nice for it to be part of the kan container. It could be a script ran just before started kan and co-exist in the same container. I have seen previous project with similar process and it works great and keep things simple for people who want to selfhost.
If this is something that people find desirable, I am down to create a PR for this.
Having to run the migration in a separate container is not very self-hosted friendly. It would be nice for it to be part of the kan container. It could be a script ran just before started kan and co-exist in the same container. I have seen previous project with similar process and it works great and keep things simple for people who want to selfhost.
If this is something that people find desirable, I am down to create a PR for this.
I think the opposite, I have a docker-compose.yml I do docker compose pull and it updates the images and I just restart my container stack, and it automatically runs the migrations needed and that's it done.
The goal was to remove the migrations from the main container, since it was making the containers final image over 1.6gb, which is quite big for just a small app.
You need to put yourself in the user shoe. People who selfhost are not using your docker-compose.yml. It helps to have an example, but it will still be 2 services to maintain instead of 1 (and we often have many more). And this issue also show that it might be confusing.
Indeed 1.6gb is a lot. Removing it might not be the right solution tho. Have you tried to look at what is taking for much space ?
You need to put yourself in the user shoe. People who selfhost are not using your docker-compose.yml. It helps to have an example, but it will still be 2 services to maintain instead of 1 (and we often have many more). And this issue also show that it might be confusing.
For context, I personally self-host around 50 services, docs, planners, VPNs, almost the whole *arr stack and more, each bundled into separate directories with their own compose files. Managing multiple services is just part of the self-hosting workflow and a dedicated migration service fits into that naturally. Since Watchtower got archived, I built my own service that keeps everything updated via a specific ruleset, and I'd recommend doing the same or finding an alternative to Watchtower that fits your needs.
This separation is also a widely adopted pattern in the self-hosting space. A good reference is AFFiNE, a Notion alternative, which follows the exact same approach with a dedicated migration service alongside the main app container. [See their compose file]
The separation is there for a clear reason too, migrations are a one-time operation per update and they don't belong in the runtime container. Their job is to run, finish, and exit. Bundling them into the main container just mixes two things that shouldn't be mixed.
Indeed 1.6gb is a lot. Removing it might not be the right solution tho. Have you tried to look at what is taking for much space ?
It wasn't the migrations causing the size, it was the entire node_modules tree including all dev dependencies being packaged into the final image. Stripping that out along with moving migrations to their own image brought the size down significantly, and putting migrations back into the main container wouldn't fix anything, it would just bring the bloat back.
The provided docker-compose.yml is the intended way to deploy, you do a docker compose pull, restart and any pending migrations just run automatically, that's it. The current setup is intentional and I don't see it changing, but I'm happy to improve the docs around the migration service if that would help clear things up for new users.
My stack is failing entirely because kan-migrate fails and nothing else continues. What is supposed to happen? How do I fix this?
My stack is failing entirely because kan-migrate fails and nothing else continues. What is supposed to happen? How do I fix this?
Can we move this into a separate issue please @onyxiarivera
Closing this one as it's been answered by @nahSystemu