Files
ai-resume/Makefile
Sam Rolfe 24590cc351 deploy: static binary and a compose project name that does not collide
Two failures from the first real deploy, both repo-side:

1. The container logged "exec /usr/bin/resume-server: no such file or
   directory" and restarted until the health gate failed. The build host has
   cgo enabled, so the binary carried the nix glibc interpreter, and the
   distroless/static image has no dynamic loader. Every SQLite path already
   uses pure-Go modernc.org/sqlite, so build with CGO_ENABLED=0 and ship a
   static binary.

2. Compose warned about orphan containers ai-resume-backend-1 and
   ai-resume-db-1: /home/sam/deployment/ai-resume on .13 already owns the
   `ai-resume` compose project (on the ai-mesh network). Sharing the name makes
   each stack visible as orphans to the other, so a `compose down
   --remove-orphans` in either could stop the other. Run the site as project
   `ai-resume-site`; the image tag stays ai-resume:local and the port binding,
   mem_limit and memswap_limit are untouched.
2026-10-26 20:53:25 +11:00

107 lines
3.6 KiB
Makefile

# Ai Resume - build entry points.
#
# `make validate` is the content gate: it is what CI and deploy.sh call.
# It exits 0 only on a clean content tree.
#
# `make build` is the site gate: it generates the templ components, compiles the
# two small binaries and writes the pre-rendered site into dist/. One binary
# (bin/resume-server) serves the whole site; there is no bundler and no Node.
PYTHON ?= python3
VALIDATOR := $(PYTHON) tools/validate_content.py
GO ?= go
TEMPL ?= templ
# The runtime image is distroless/static (deploy/Dockerfile): no libc, no
# dynamic loader. Everything the server needs is pure Go (modernc.org/sqlite),
# so a static binary is buildable and is what the container can actually exec.
# Without this the build host's cgo links the nix glibc loader and the container
# fails with "exec /usr/bin/resume-server: no such file or directory".
CGO_ENABLED ?= 0
BIN := bin
DIST := dist
.PHONY: build dist generate dev test validate validate-self-test fmt vet clean help \
corpus corpus-sync corpus-rebuild corpus-audit corpus-verify corpus-demo corpus-test
help:
@echo "make build templ generate, compile bin/, no dist"
@echo "make dist build, then pre-render content into dist/"
@echo "make dev pre-render into dist/ and serve it on 127.0.0.1:8096"
@echo "make generate run templ generate (generated files are not committed)"
@echo "make test go test ./... plus the validator self-test"
@echo "make validate validate content/** front-matter against the frozen schema"
@echo "make fmt vet gofmt / go vet over cmd and internal"
@echo "make clean remove bin/ and dist/"
@echo ""
@echo "corpus (Phase 4, python3 -m corpus.cli):"
@echo "make corpus rebuild the corpus from content/ (drops the collection)"
@echo "make corpus-sync incremental update; only changed documents are re-embedded"
@echo "make corpus-audit freshness + drift audit (exit 1 on findings)"
@echo "make corpus-verify check the index against content/ and Qdrant"
@echo "make corpus-demo same query with and without an area filter"
@echo "make corpus-test corpus unit tests (no container, no network)"
build: generate
@mkdir -p $(BIN)
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -trimpath -buildvcs=false -o $(BIN)/resume-build ./cmd/build
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -trimpath -buildvcs=false -o $(BIN)/resume-server ./cmd/server
dist: build
@$(BIN)/resume-build --dist $(DIST)
dev: dist
@RESUME_DIST=$(DIST) $(BIN)/resume-server
generate:
@command -v $(TEMPL) >/dev/null || { echo "templ is not on PATH; run this inside 'nix develop'"; exit 1; }
@$(TEMPL) generate
test: generate validate-self-test
@$(GO) test ./...
validate:
@$(VALIDATOR)
validate-self-test:
@$(VALIDATOR) --self-test
fmt:
@gofmt -l -w cmd internal
vet:
@$(GO) vet ./...
# -- corpus (Phase 4, docs/phase-4-corpus.md) --------------------------------
#
# The corpus is data, not a build artefact: it lives in data/corpus/ (gitignored)
# and in Qdrant. RESUME_QDRANT_URL defaults to http://127.0.0.1:6333 and
# RESUME_EMBED_PROVIDER defaults to local-hashing; production sets both in the
# environment, never in this file.
CORPUS := $(PYTHON) -m corpus.cli
corpus: corpus-rebuild
corpus-rebuild:
@$(CORPUS) rebuild
corpus-sync:
@$(CORPUS) sync
corpus-audit:
@$(CORPUS) audit --fail-on-findings
corpus-verify:
@$(CORPUS) verify
corpus-demo:
@$(CORPUS) demo-filter --query "distributed audio endpoints" --area edge
corpus-test:
@$(PYTHON) -m unittest discover -s corpus/tests -t .
clean:
@rm -rf $(BIN) $(DIST)