aboutsummaryrefslogtreecommitdiffstats
path: root/bin/deploy.sh
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-03-04 19:07:57 +0100
committerArmand Philippot <git@armandphilippot.com>2022-03-04 19:07:57 +0100
commit2b5af5146d7c22eac4a5150a038a05620ec5b8a3 (patch)
treef534dd82d0f16de158a783e39082dfe9a00da85a /bin/deploy.sh
parent79e3429ea8fb590f82b11f2b19a26427f2d1da4f (diff)
build(docker): make Docker deployement compatible with Docker Swarm
I also added a custom script to deploy the services with Docker Swarm. Without it, Docker cannot read the `.env` file. Since I'm using a variable to define the registry, the script is required.
Diffstat (limited to 'bin/deploy.sh')
-rwxr-xr-xbin/deploy.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/bin/deploy.sh b/bin/deploy.sh
new file mode 100755
index 0000000..31b8cdb
--- /dev/null
+++ b/bin/deploy.sh
@@ -0,0 +1,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 "$@"