Where to put the php artisan migrate command

北慕城南 提交于 2019-11-28 09:22:10

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

to run all migrate u need to be inside ur container, for that u need to run ur containers with docker-compose up, here u need to be with terminal in the directory where ur docker-compose.yml file is.

after that,and with the same place of docker-compose.yml file, run this commande to be inside ur container :

docker exec -it name_of_ur_server bash

and when u will be inside ur container, go to ur shared app inside the container, i think here is app so cd app.

after all of this run :

php artisan migrate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!