summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.env.example1
-rwxr-xr-xbin/deploy.sh27
-rw-r--r--docker-compose.yml2
3 files changed, 30 insertions, 0 deletions
diff --git a/.env.example b/.env.example
index 4d98551..dbfb664 100644
--- a/.env.example
+++ b/.env.example
@@ -24,6 +24,7 @@ NEXT_PUBLIC_GRAPHQL_API="https://$APP_BACKEND_DOMAIN$APP_GRAPHQL_ENDPOINT"
#NEXT_PUBLIC_STAGING_GRAPHQL_API="https://$APP_STAGING_BACKEND_DOMAIN$APP_STAGING_GRAPHQL_ENDPOINT"
# Common
+APP_DOCKER_REGISTRY_DOMAIN="127.0.0.1:5000"
APP_AUTHOR_NAME="Your Name"
APP_AUTHOR_EMAIL="your@email.com"
APP_AUTHOR_URL="https://www.yourWebsite.com/"
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 "$@"
diff --git a/docker-compose.yml b/docker-compose.yml
index 8d0ad57..791f1ef 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,6 +1,7 @@
version: '3.8'
services:
apcom:
+ image: ${APP_DOCKER_REGISTRY_DOMAIN}/apcom
build:
context: .
dockerfile: Dockerfile
@@ -16,6 +17,7 @@ services:
- '${APP_DOCKER_PORT:-3000}:${APP_DOCKER_PORT:-3000}'
restart: always
apcom-staging:
+ image: ${APP_DOCKER_REGISTRY_DOMAIN}/apcom-staging
build:
context: .
dockerfile: Dockerfile