anvilsign in

collin/anvil

1#!/usr/bin/env bash
2# Cross-compile anvil natively on the build host (Mac) and ship the image to
3# hagrid. NOT run on the VPS — it never compiles anything.
4#
5# Uses cargo-zigbuild to cross-compile a fully static x86_64-musl binary at
6# native speed (no QEMU), stages it at deploy/anvild, builds a thin image that
7# just COPYs it in, and pipes the image to hagrid via docker load.
8#
9# Prereqs (one-time):
10# brew install zig
11# cargo install cargo-zigbuild
12# rustup target add x86_64-unknown-linux-musl
13set -euo pipefail
14
15IMAGE="${ANVIL_IMAGE:-anvil:latest}"
16REMOTE="${ANVIL_REMOTE:-hagrid}"
17TARGET="x86_64-unknown-linux-musl"
18
19cd "$(dirname "$0")/.."
20
21echo "==> cross-compiling anvild for $TARGET (native, via zig)"
22cargo zigbuild --release --target "$TARGET" --bin anvild
23
24echo "==> staging binary at deploy/anvild"
25cp "target/$TARGET/release/anvild" deploy/anvild
26
27echo "==> building $IMAGE (just COPYs the binary — fast)"
28docker build --platform linux/amd64 -t "$IMAGE" .
29
30echo "==> shipping $IMAGE to $REMOTE"
31docker save "$IMAGE" | gzip | ssh "$REMOTE" 'docker load'
32
33rm -f deploy/anvild
34echo "==> done. On $REMOTE, run ./deploy/run.sh to (re)start the container."