anvilsign in

collin/anvil

1#!/usr/bin/env bash
2# Stage the anvild binary that the image COPYs in. NOT run on the VPS — it
3# never compiles anything.
4#
5# Uses cargo-zigbuild to cross-compile a fully static x86_64-musl executable at
6# native speed (no QEMU) and leaves it at deploy/anvild, which is where the
7# Dockerfile expects it. Building and pushing the image is compose's job from
8# there (see compose.yaml); ./deploy/deploy.sh runs both halves.
9#
10# Prereqs (one-time):
11# zig (dnf install zig, or brew install zig)
12# cargo install cargo-zigbuild
13# rustup target add x86_64-unknown-linux-musl
14set -euo pipefail
15
16TARGET="x86_64-unknown-linux-musl"
17
18cd "$(dirname "$0")/.."
19
20# macOS terminals default to a 256 open-file soft limit; zig's linker opens
21# every rlib at once and dies with ProcessFdQuotaExceeded. Raise it for this
22# process (children inherit it).
23ulimit -n 4096 2>/dev/null || true
24
25echo "==> cross-compiling anvild for $TARGET (native, via zig)"
26cargo zigbuild --release --target "$TARGET" --bin anvild
27
28echo "==> staging binary at deploy/anvild"
29cp "target/$TARGET/release/anvild" deploy/anvild
30
31# Deliberately left in place: `docker compose build` runs after this and needs
32# it in the context. It is gitignored, and the next build overwrites it.
33echo "==> staged. Build the image with: docker compose build (or ./deploy/deploy.sh)"