shipping/update.sh
2025-01-14 22:09:35 +01:00

39 lines
1.3 KiB
Bash

#!/bin/bash
# Put the application into maintenance mode
echo "Putting the application into maintenance mode..."
docker exec -it --user root shipping-php bash -c "php artisan down"
# Change ownership of files to 1001:1001 inside the container
echo "Changing ownership of files to 1001:1001..."
docker exec -it --user root shipping-php bash -c "chown -R 1001:1001 ."
# Pull the latest changes from git
echo "Pulling latest changes from Git..."
git pull
# Run npm build inside the Docker container
echo "Running npm build..."
docker compose run npm run build-only
# Change ownership of files to www-data:www-data before running artisan optimize
echo "Changing ownership of files to www-data:www-data..."
docker exec -it --user root shipping-php bash -c "chown -R www-data:www-data ."
# Execute artisan optimize in the PHP container
echo "Executing artisan optimize in PHP container..."
docker exec -it --user root shipping-php bash -c "php artisan optimize"
docker exec -it --user root shipping-php bash -c "php artisan config:clear"
# Restart Docker Compose services
echo "Restarting Docker Compose services..."
docker compose restart
# Put the application into live mode
echo "Putting the application into live mode..."
docker exec -it --user root shipping-php bash -c "php artisan up"
echo "Script completed successfully."