-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprod-deploy.sh
executable file
·45 lines (32 loc) · 1.12 KB
/
prod-deploy.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# deploy-prod.sh
# Exit on any error
set -e
BASE_DIR="./"
SERVICES=("client" "admin")
export PROJECT="rux"
echo "Starting production deployment process..."
# Create network if it doesn't exist
docker network create ${PROJECT}_network 2>/dev/null || echo "Network already exists"
for SERVICE in "${SERVICES[@]}"; do
echo "Processing $SERVICE..."
cd "$BASE_DIR/$SERVICE"
# Down the container and remove volumes
echo "Stopping $SERVICE containers and cleaning up..."
docker compose --env-file .env.prod -f docker-compose.prod.yml down -v
# Remove old images
echo "Removing old images for $SERVICE..."
docker image prune -f --filter "label=com.docker.compose.project=${PROJECT}"
# Clean build cache
echo "Cleaning build cache..."
docker builder prune -f
# Rebuild with no cache
echo "Rebuilding $SERVICE..."
docker compose --env-file .env.prod -f docker-compose.prod.yml build --no-cache
# Start
echo "Starting $SERVICE..."
docker compose --env-file .env.prod -f docker-compose.prod.yml up -d
cd -
done
echo "All services rebuilt and running"
docker ps