#!/usr/bin/env bash
# Run ONCE, on the manager node (vps2), after both boxes have joined the
# swarm. Labels the worker (vps1) so the Forgejo stack's placement constraint
# (node.labels.role == forge) schedules there and nowhere else.
set -euo pipefail

WORKER_HOSTNAME="${1:?usage: $0 <worker_node_hostname_or_id> (see: docker node ls)}"

docker node update --label-add role=forge "$WORKER_HOSTNAME"

echo
echo "Labels on ${WORKER_HOSTNAME}:"
docker node inspect "$WORKER_HOSTNAME" --format '{{.Spec.Labels}}'
