-
Notifications
You must be signed in to change notification settings - Fork 319
/
prod-deploy.sh
executable file
·35 lines (26 loc) · 1.08 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
#!/usr/bin/env bash
# Updates the production instance of NUSMods without downtime.
# Usage: prod-deploy.sh
# Exit when any command fails
set -e
# Echo commands
set -x
git pull
# At the end of this script, we'll want to only keep cached builds of both the
# current and new deploys.
# --force simply disables confirmation.
docker system prune --all --force
# Build and deploy green, we have 2 versions now
export GIT_COMMIT_HASH=$(git rev-parse HEAD)
docker-compose --project-name=green -f docker-compose.prod.yml build --no-cache
docker-compose --project-name=green -f docker-compose.prod.yml up -d
# Wait for green to start
sleep 2m
# Restart blue, bringing it to latest
docker-compose --project-name=blue -f docker-compose.prod.yml build # Use cached build from green
docker-compose --project-name=blue -f docker-compose.prod.yml down --remove-orphans
docker-compose --project-name=blue -f docker-compose.prod.yml up -d
# Wait for blue to start
sleep 2m
# Tear down green, we can now reuse it for next deploy
docker-compose --project-name=green -f docker-compose.prod.yml down --remove-orphans