I'm using docker for my projects, mostly Laravel ones, which has the configurement of building a MySQL container and an app container.
The containers respectively is named "db" and "app".
The .env file is therefore configured after the hostname "db" in order to have the served webserver properly initialised
This enforces the developer to be inside the container in order to run appropiate commands that has anything to do with the database connection, otherwise giving error as the environment believes we are talking about a mysql instance at the computer. (right?)
Therefore, a script in the project root directory is made in order to ease this.
./cmd.sh artisan migrate (Works)
php artisan migrate (Does not) - unknown database
This concludes to the problem of mine, which I'm here for.
As you might see, this is oddly specific to MacOS environment and that would be true. Having the need of this script to work cross-os, meaning painlessly for Linux and Windows developers as well, is somewhat of a struggle of mine.
So, the issue in TLDR: How can I arrange this method of ease to work for all OS?
Using the current way has these issues:
Linux:
- 1000 is the default user, not 33. Simply changing 33 to 1000 kind of fixes it
- changing to 1000 makes it not working for mac though
Windows:
- Needs powershell for bash, otherwise (cannot find the tty input device)
- Powershell cant read the sh syntax
I kind of want to try staying away from using multiplie files, one for each os, as solution.
So, what am I missing here, is this even doable and where could I read about making this doable?
Thank you so much in advance and so sorry about the wall of text.
TLDR: For docker projects, how can i make a script that can run the container command for all Operative systems?