Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (78 loc) · 4.23 KB
/
Copy pathMakefile
File metadata and controls
101 lines (78 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
.PHONY: fmt fmt-check clippy build test test-short integration-test clean dev dev-external dev-down dev-reset dev-logs dev-db go-test go-test-short db-backup db-restore db-restore-drill
CARGO := cargo
CONTRACTS_DIR := packages/contracts
WASM_TARGET := wasm32-unknown-unknown
fmt:
cd $(CONTRACTS_DIR) && $(CARGO) fmt --all
fmt-check:
cd $(CONTRACTS_DIR) && $(CARGO) fmt --all -- --check
clippy:
cd $(CONTRACTS_DIR) && $(CARGO) clippy --all-targets --all-features -- -D warnings
build:
cd $(CONTRACTS_DIR) && $(CARGO) build --target $(WASM_TARGET) --release
test:
cd $(CONTRACTS_DIR) && $(CARGO) test --all
integration-test:
cd $(CONTRACTS_DIR) && $(CARGO) test --all --lib
go-test:
cd apps/api && go test -race -timeout 120s ./...
go-test-short:
cd apps/api && go test -race -short -timeout 60s ./...
clean:
cd $(CONTRACTS_DIR) && $(CARGO) clean
# Docker Compose — local development
#
# By default, all services bind to 127.0.0.1 (loopback only) for security.
# This prevents accidental exposure on shared networks.
#
# For multi-machine setups, opt in to external binding:
# make dev-external
#
# See docker-compose.external.yml and docs/security/dev-setup.md.
dev: ## Start all services with Docker Compose (migrations auto-apply)
docker compose up --build
dev-external: ## Start all services with external binding (0.0.0.0) — use only on trusted networks
docker compose -f docker-compose.yml -f docker-compose.external.yml up --build
dev-down: ## Stop all services
docker compose down
dev-reset: ## Destructive reset of database volumes and restart (use only for full rebuilds)
docker compose down -v && docker compose up --build
dev-logs: ## Tail logs for all services
docker compose logs -f
dev-db: ## Open a psql shell in the dev database
docker compose exec postgres psql -U nester nester_dev
dev-seed: ## Apply scripts/seed.sql to the running dev database (re-runnable)
docker compose exec -T postgres psql -v ON_ERROR_STOP=1 -U nester nester_dev < scripts/seed.sql
# The documented reset for #1122. Drops the schema, lets the API container
# re-apply every migration on start, then loads the fixture set — so a
# contributor whose database has drifted gets back to a known state without
# guessing which migration they are missing.
dev-db-reset: ## Recreate the dev schema, re-run migrations, and re-seed
docker compose exec -T postgres psql -v ON_ERROR_STOP=1 -U nester nester_dev -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;'
docker compose restart api
@echo "Waiting for migrations to apply..."
@until docker compose exec -T postgres psql -tA -U nester nester_dev -c "SELECT to_regclass('public.users')" | grep -q users; do sleep 1; done
$(MAKE) dev-seed
# Backup / restore (nester#795). See docs/database-backup-restore.md for the
# full runbook, retention/PITR guidance, and the restore-drill checklist.
db-backup: ## Back up the dev database to ./backups/nester_<timestamp>.dump
DATABASE_DSN="postgres://nester:nester_dev_password@localhost:5432/nester_dev?sslmode=disable" \
scripts/db-backup.sh
db-restore: ## Restore a backup: make db-restore FILE=./backups/nester_<timestamp>.dump
@if [ -z "$(FILE)" ]; then \
echo "Usage: make db-restore FILE=./backups/nester_<timestamp>.dump"; \
exit 1; \
fi
DATABASE_DSN="postgres://nester:nester_dev_password@localhost:5432/nester_dev?sslmode=disable" \
scripts/db-restore.sh "$(FILE)"
db-restore-drill: ## Restore the most recent local backup into a scratch DB (nester_restore_drill) without touching nester_dev
@latest="$$(find ./backups -maxdepth 1 -name 'nester_*.dump' 2>/dev/null | sort | tail -1)"; \
if [ -z "$$latest" ]; then \
echo "No backups found in ./backups — run 'make db-backup' first."; \
exit 1; \
fi; \
echo "Restoring $$latest into scratch database nester_restore_drill ..."; \
docker compose exec -T postgres psql -v ON_ERROR_STOP=1 -U nester -d postgres -c "DROP DATABASE IF EXISTS nester_restore_drill;"; \
docker compose exec -T postgres psql -v ON_ERROR_STOP=1 -U nester -d postgres -c "CREATE DATABASE nester_restore_drill;"; \
DATABASE_DSN="postgres://nester:nester_dev_password@localhost:5432/nester_restore_drill?sslmode=disable" \
scripts/db-restore.sh "$$latest" "postgres://nester:nester_dev_password@localhost:5432/nester_restore_drill?sslmode=disable"