Sylius-Standard icon indicating copy to clipboard operation
Sylius-Standard copied to clipboard

docker-compose.prod.yml reload fixture on docker restart

Open duchnoun opened this issue 2 years ago • 6 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

duchnoun avatar Aug 19 '22 08:08 duchnoun

no body got a response ? thanks :)

duchnoun avatar Sep 09 '22 08:09 duchnoun

@Ferror looks like your work.

vvasiloi avatar Sep 09 '22 09:09 vvasiloi

@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 avatar Sep 14 '22 16:09 Ferror

@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.

vvasiloi avatar Sep 14 '22 16:09 vvasiloi

@vvasiloi i agree with you +1.

duchnoun avatar Sep 20 '22 08:09 duchnoun

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

vasilvestre avatar Sep 22 '22 14:09 vasilvestre

In https://github.com/Sylius/Sylius-Standard/pull/859/files we introduced an environment variable that can easily turn loading fixtures off

Ferror avatar Dec 07 '22 21:12 Ferror