#!/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 registry.rose-ash.com:5000/celery-l1-server:latest .

echo "=== Pushing to registry ==="
docker push registry.rose-ash.com:5000/celery-l1-server:latest

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

echo "=== Done ==="
docker stack services celery
