aboutsummaryrefslogtreecommitdiffstats
path: root/bin/deploy.sh
blob: b843b977655770547c4feffde53ebf030f6da51c (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
28
29
30
31
#!/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 [OPTIONS]\n"
  exit 1
}

deploy() {
  [ $# -eq 0 ] && error

  _stack_name="$1"
  shift

  loadenvs
  docker stack deploy -c docker-compose.yml "$@" "$_stack_name"
}

deploy "$@"