docker laravel 的自动部署
docker部署在jenkins上:
cd /www/wwwroot/laravel-docker
git pull
if [ $? -ne 0 ]; then
echo “============================git pull failed==================================”
exit 1
else
echo “===========================git pull succeed==================================”
fi
docker-compose build && docker-compose up -d
if [ $? -ne 0 ]; then
echo “============================ docker-compose up failed==================================”
exit 1
else
echo “===========================docker-compose up succeed==================================”
fi
docker-compose exec -T –user root laravel_php chown nginx: -R ./
if [ $? -ne 0 ]; then
echo “============================composer install failed==================================”
exit 1
else
echo “===========================composer install succeed==================================”
fi
docker-compose exec -T –user nginx laravel_php composer install –prefer-dist –no-scripts -q -o && composer dumpautoload
if [ $? -ne 0 ]; then
echo “============================composer install failed==================================”
exit 1
else
echo “===========================composer install succeed==================================”
fi
docker-compose exec -T –user nginx laravel_php php artisan config:clear && php artisan migrate –force
if [ $? -ne 0 ]; then
echo “============================php artisan migrate failed==================================”
exit 1
else
echo “===========================php artisan migrate succeed==================================”
fi
docker-compose exec -T –user nginx laravel_php php artisan queue:restart
if [ $? -ne 0 ]; then
echo “============================php artisan queue failed==================================”
exit 1
else
echo “=========================== php artisan queue succeed==================================”
fi