I have a docker compose file with an app container and a postgres container.
The app one depends on postgres container.
I would like before the app container starts to connect to the postgres and run a script to create a database there. How can I do this in docker compose? Is there any way to run something in the middle of the dependency?
Or should I do it when I connect to the server through ssh, to run docker compose up and down, in the deploy stage. In this way I would also need to somehow install psql in the server. I would prefer the first one.
Can you point me in the right direction?