docker-compose.prod.yml reload fixture on docker restart
duchnoun opened this issue · 7 comments
Hi,
Can't understand why fixture are reload (and delete all data) if container restart. (In case of docker-compose.prod.yml)
In documentary we launch : docker compose -f docker-compose.prod.yml exec php bin/console sylius:fixtures:load --no-interaction
Ok it's normal the first time if we want fixture.
But why it load it on : https://github.com/Sylius/Sylius-Standard/blob/1.12/docker/php/docker-entrypoint.sh (line 26)
In production data shouldn't be erase ? Or i mistake ?
Thanks
no body got a response ? thanks :)
@duchnoun The docker-entrypoint.sh is shared for all environments. Why did I add the fixture loading? It's much better DX at the beginning. When you start a project and see a proper store instead of an error page with information that the "Channel was not found". If it does not suit your needs - feel free to remove it for your project 😃
PS. Thx @vvasiloi for a ping 😄
@Ferror the intention was good, but it ended up being a bad DX in a different way.
I suggest you do that conditionally.
Don't do it if env is prod and add a state for initialization.
For the state, a common approach is to mount a dir or create a file after the initilization.
Another option is to run bin/console doctrine:query:sql
and check if channels exists.
Last but not least, make it possible to easily opt-out, with an env var for example.
IMO and as dunglas does in his docker, there's a comment that says "after first install feel free to remove this"
The first install is simpler with this, people should edit files to match the behaviour they want to have
In https://github.com/Sylius/Sylius-Standard/pull/859/files we introduced an environment variable that can easily turn loading fixtures off