-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·26 lines (18 loc) · 815 Bytes
/
Copy pathdeploy.sh
File metadata and controls
executable file
·26 lines (18 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
# deploy.sh - Pull latest code and rebuild Docker containers
# Exit immediately if a command exits with a non-zero status,
# treat unset variables as an error, and propagate errors in pipelines
set -euo pipefail
# Determine script directory and cd into it
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "\n=>> Pulling latest changes from 'origin/master'..."
git pull origin master
echo "\n=>> Stopping containers..."
sudo docker compose down
echo "\n=>> Pruning build cache..."
sudo docker builder prune -f
sudo docker buildx prune -f
echo "\n=>> Building and starting containers..."
sudo docker compose --env-file ./.env build --no-cache --pull && sudo docker compose --env-file ./.env up --force-recreate --build -d
echo "\n=>> Deployment complete!"