anvilsign in

collin/anvil

1#!/usr/bin/env bash
2# Build and deploy anvil to hagrid.
3#
4# Two halves, because the image carries a prebuilt binary rather than compiling
5# in Docker:
6#
7# 1. build.sh cross-compiles anvild and stages it at deploy/anvild,
8# 2. `hag deploy` does the rest from compose.yaml — build the image, push it
9# to the registry, copy compose.yaml to the host, pull and recreate there.
10#
11# hag is the shared deploy tool for every project on hagrid and lives in the
12# hagrid repo, so nothing here is anvil-specific any more. Install it once with
13# `~/Code/hagrid/hag install`.
14#
15# Usage: ./deploy/deploy.sh [hag deploy options]
16# e.g. ./deploy/deploy.sh -n dry run (skips the compile)
17# ./deploy/deploy.sh --host other deploy elsewhere
18#
19# Afterwards: `hag status`, `hag logs -f`, `hag restart`, `hag down`.
20set -euo pipefail
21
22if ! command -v hag >/dev/null; then
23 echo "deploy.sh: hag is not on PATH — run: ~/Code/hagrid/hag install" >&2
24 exit 1
25fi
26
27# A dry run reports what would happen and changes nothing, so spending two
28# minutes on a release build first would defeat the point. hag reads the image
29# reference out of compose.yaml, which does not need the binary to exist.
30DRY_RUN=0
31for arg in "$@"; do
32 case "$arg" in
33 -n | --dry-run) DRY_RUN=1 ;;
34 esac
35done
36
37[ "$DRY_RUN" = 1 ] || "$(dirname "$0")/build.sh"
38
39exec hag deploy "$@"