EDIT:
It took me a day to realise it but this is actually an antipattern. Composer should not run docker scripts.
My solution is this:
"scripts": {
"php bin/console/doctrine.php orm:schema-tool:create",
"php bin/console/doctrine.php orm:schema-tool:update --force",
"php bin/console/fixtures.php"
},
---
Is it possible to pass variables to composer scripts?
I have this respository that runs in docker. When I need to update fixtures or database schema or pretty much anything else I need to run docker exec I would like to make that at least semi-automatic. So that I can type something like composer run refresh_app and everything that needs to be done gets done.
With scripts like these:
"scripts": {
"db:create": "docker exec -i my_container_name bash -c \"cd /www; php bin/console/doctrine.php orm:schema-tool:create\"",
"db:update": "docker exec -i my_container_name bash -c \"cd /www; php bin/console/doctrine.php orm:schema-tool:update --force\"",
"db:fixtures": "docker exec -i my_container_name bash -c \"cd /www; php bin/console/fixtures.php\""
},
I want to pass the my_container_name in variable. Possibly do something like this:
"scripts": {
"db:create": "docker exec -i $CONTAINER_ID bash -c \"cd /www; php bin/console/doctrine.php orm:schema-tool:create\"",
"db:update": "docker exec -i $CONTAINER_ID bash -c \"cd /www; php bin/console/doctrine.php orm:schema-tool:update --force\"",
"db:fixtures": "docker exec -i $CONTAINER_ID bash -c \"cd /www; php bin/console/fixtures.php\""
},