summaryrefslogtreecommitdiffstats
path: root/bin/deploy.sh
blob: 31b8cdb19199f3a18f197fdf299ca892703efb52 (plain)
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
#!/usr/bin/env sh
#
# deploy.sh
#
# Deploy both services using Docker swarm.
#
# The registry domain is set in dotenv file but docker stack cannot read it.
# So a custom deploy script is required to load .env first.
# See: https://github.com/moby/moby/issues/29133

loadenvs() {
  set -a && . ./.env && set +a
}

error() {
  printf "Error: stack name not defined.\n"
  printf "Usage: sh deploy.sh your-stack-name\n"
  exit 1
}

deploy() {
  [ $# -ne 1 ] && error
  loadenvs
  docker stack deploy -c docker-compose.yml "$1"
}

deploy "$@"