#!/bin/bash
set -e

cd "$(dirname "$0")"

echo "=== Pulling latest code ==="
git pull

echo "=== Building Docker image ==="
docker build --build-arg CACHEBUST=$(date +%s) -t git.rose-ash.com/art-dag/l2-server:latest .

echo "=== Redeploying activitypub stack ==="
docker stack deploy -c docker-compose.yml activitypub

echo "=== Restarting proxy nginx ==="
docker service update --force proxy_nginx

echo "=== Done ==="
docker stack services activitypub
