Files
allmende/Makefile
T
nilsandClaude Sonnet 5.5 0cfb59c469 Orderly shutdown on SIGHUP too, forced exit when stuck; version in the image
SIGINT, SIGTERM and SIGHUP all shut the node down in order (SIGTERM is what a
Kubernetes pod termination sends). A second signal, or 20 seconds (below the
30 s Kubernetes grants), stops the process at once, so a stuck shutdown cannot
hang.

The binary knows its version (allmende version, and the 'node running' log
line); the image is built with the commit as version and 'make image' pushes it
tagged with that commit, refusing a dirty tree.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
2026-11-18 13:08:14 +01:00

51 lines
1.8 KiB
Makefile

BIN := bin/allmende
REGION ?= u1j# Bonn; several are allowed: make run REGION="u1j u1h" (u1h is Cologne)
DATA ?=
FLAGS := $(if $(DATA),--data $(DATA))
.PHONY: help build run init test vet web web-test e2e check clean docker image
help: ## list the targets
@grep -E '^[a-z-]+:.*## ' $(MAKEFILE_LIST) | awk -F':.*## ' '{printf " %-10s %s\n", $$1, $$2}'
build: ## build the node into bin/allmende (the UI is already embedded)
go build -o $(BIN) ./cmd/allmende
init: build ## create your identity (once): make init [DATA=dir]
$(BIN) init $(FLAGS)
run: build ## run a node (default region Bonn): make run [REGION=u1j] [DATA=dir]
$(BIN) run $(FLAGS) $(foreach r,$(REGION),--region $(r))
docker: ## build the container image (allmende:dev)
docker build -t allmende:dev .
IMAGE ?= git.stinnesbeck.com/nils/allmende
image: ## build and push the image, tagged with the commit (clean tree only); prints the tag to put in k8s/base/kustomization.yaml
@test -z "$$(git status --porcelain)" || { echo "commit your changes first: the tag must name what is in the image"; exit 1; }
@tag=$$(git rev-parse --short HEAD) && \
docker build --build-arg VERSION=$$tag -t $(IMAGE):$$tag . && \
docker push $(IMAGE):$$tag && \
echo "pushed $(IMAGE):$$tag -> set newTag: $$tag in k8s/base/kustomization.yaml"
vet: ## go vet
go vet ./...
test: ## Go tests with the race detector
go test -race ./...
web: ## rebuild web/dist after changing web/src (needs Node.js)
cd web && npm ci && npm run build
web-test: ## type-check and test the web UI (needs Node.js)
cd web && npm ci && npm run typecheck && npm test
e2e: ## two real nodes end to end (needs Node.js and web/node_modules)
scripts/e2e.sh
check: vet test web-test e2e ## everything: vet, Go tests, web checks, end to end
clean: ## remove built binaries
rm -rf bin