Where to put the php artisan migrate command

This is how I solved it .Created a bash script called run.sh and added the php artisan migrations commands followed by the php serve command.

run.sh

#!/bin/sh

cd /app  
php artisan migrate:fresh --seed
php artisan serve --host=0.0.0.0 --port=$APP_PORT

Added entrypoint to the Dockerfile removing the CMD in the end which will run the commands desired.

copy ./run.sh /tmp    
ENTRYPOINT ["/tmp/run.sh"]

Remove the command from the docker-compose.yml

Leave a Comment