Part-DB / Part-DB-server

Part-DB is an Open source inventory management system for your electronic components
https://docs.part-db.de/
GNU Affero General Public License v3.0
941 stars 108 forks source link

Running migrations in k8s-deployed container #728

Open plaes opened 1 month ago

plaes commented 1 month ago

Although current documentation contains example on how to run migrations when running Part-DB inside docker, it's not a suitable way to run it inside container deployed in k8s (unless you do some nasty tricks).

In k8s, one should exec into container, and then invoke migrate command using sudo -E -u www-data like this: sudo -E -u www-data php bin/console doctrine:migrations:migrate

I'm not sure where to add this in the documentation though (maybe add as alternative next to docker install).

Also, I can see that helm-chart uses initContainer as a solution (but this is nowadays considered inferior to using separate K8s Job triggered from Helm hook): https://github.com/Part-DB/helm-charts/blob/b2514f3ae03f0d4a59047781260672bd01c433ec/charts/part-db/templates/statefulset.yaml#L38-L45

jbtronics commented 1 month ago

I plan to implement some automatic migration mechanism for the new docker image (https://github.com/Part-DB/Part-DB-server/discussions/562), as this also makes upgrades much easier.

However, as it's possible that these fail, some automatic backup and recovery mechanism is required, which is not that trivial to implement.