-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·32 lines (24 loc) · 975 Bytes
/
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
#!/bin/bash -l
set -e
echo "=== Starting Deployment ==="
LAST_DEPLOY_FILE=".last-deploy"
LAST_DEPLOY_SHA=$([ -f $LAST_DEPLOY_FILE ] && cat $LAST_DEPLOY_FILE || echo "main")
CUR_DEPLOY_SHA=$(git rev-parse HEAD)
echo "Deploying: $LAST_DEPLOY_SHA -> $CUR_DEPLOY_SHA"
echo "--- Rebuilding containers ---"
docker compose -f docker-compose.production.yml build
CLIENT_CHANGED=$(git diff --quiet $LAST_DEPLOY_SHA $CUR_DEPLOY_SHA -- packages/client && echo false || echo true)
echo "--- Rebuilding Client ---"
if [[ $CLIENT_CHANGED == "true" ]]; then
docker compose -f docker-compose.production.yml up client
else
echo "Skipped: client unchanged"
fi
echo "--- Stopping containers ---"
docker compose -f docker-compose.production.yml down
echo "--- Migrating data ---"
.migrations/001_upgrade-postgres-16_up.sh
echo "--- Starting containers ---"
docker compose -f docker-compose.production.yml up router -d
echo "=== All Done ==="
echo $CUR_DEPLOY_SHA > $LAST_DEPLOY_FILE