#!/bin/sh # Build images and deploy ATLAS stack to local swarm. set -e cd "$(dirname "$0")/.." [ -f .env ] && set -a && . .env && set +a if [ -n "$(git status --porcelain)" ]; then echo "ERROR: Working tree is dirty. Commit your changes before deploying." >&2 exit 1 fi BUILD_COMMIT="$(git rev-parse --short HEAD)" BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)" echo "=== Building commit $BUILD_COMMIT ===" echo "=== Ensuring swarm mode ===" docker info --format '{{.Swarm.LocalNodeState}}' | grep -q "active" || docker swarm init echo "=== Creating overlay network ===" docker network inspect authelia_dev >/dev/null 2>&1 || \ docker network create -d overlay --attachable authelia_dev echo "=== Building images ===" docker compose build \ --build-arg BUILD_COMMIT="$BUILD_COMMIT" \ --build-arg BUILD_TIME="$BUILD_TIME" echo "=== Deploying stack ===" docker stack deploy -c stack.yml atlas echo "=== Force-updating local images ===" docker service update --force --image atlas-ss-atlas:latest atlas_ss-atlas docker service update --force --image git.nixc.us/a250/authelia:dev-authelia atlas_authelia echo "" echo "=== Ready. Visit https://bc.a250.ca ==="