I’m trying to set up a docker environment, with a php-apache container along with a postgres container. Actually I succeeded and it kind of works. Thing is I just got the server from a previous coworker, and I’ll eventually update it but for now I just want to make it work as it is.
So basically, my php container creates the database relations with symfony command
doctrine:schema:create and my postgres container populates the data with a .sql script. I thought I could put these commands as entrypoint to each container, but the .sql script can only be executed once the symfony command has run and finished.
So for now I just run the .sql script by hand though
docker exec -it <container id> once everything is set up, and it works, but can obviously not stay that way.
I am wondering what would be the best approach for this. Should I just put a script in my postgres container that will wait for the relations to exist in the db before running the .sql script? Should I add postgres to my php container in order to run all commands from there? Neither looks like a nice thing to do, and I’m sure this configuration is not something unusual.
I’m relativerly new to Docker and I am not sure I get the whole picture yet, so maybe I’m just talking nonsense and there’s no real issue to my situation. But if I could get a little pointer to which direction to go to it would be great.