Skip to content

Commit 7b83c8f

Browse files
karngyanclaude
andcommitted
chore(make): split dev into dev-api / dev-web, auto-migrate first
Two issues this fixes: 1. `make dev` worked off a fresh sqlite that never had migrations applied; the server logged a wall of "no such table" errors from the ingest and rollup schedulers on first tick. 2. Running `portless tempo make dev` injects a single PORT env into the whole invocation, which both servers tried to bind. The fix is two separate make targets so each can be wrapped by portless individually: portless tempo make dev-web # https://tempo.localhost portless api.tempo make dev-api # https://api.tempo.localhost Then VITE_API_TARGET=https://api.tempo.localhost lets the SPA's /api proxy point at the API subdomain. Changes: - New `dev-api` target runs migrate-up then air. Honors PORT / TEMPO_LISTEN. - New `dev-web` target runs `pnpm -C web dev`. Honors PORT and prints the resolved VITE_API_TARGET so the user sees where /api routes. - `dev` now `migrate-up`s before starting both, so fresh clones Just Work. - migrate-{up,down,status} use `mise exec --` so they work in subprocess shells without mise activation (same portless concern). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5d76c3a commit 7b83c8f

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help dev build embed-copy test lint fmt ci clean web-install web-dev web-build migrate-up migrate-down migrate-status sqlc-generate openapi-validate openapi-check-frontend docker-build docker-up docker-down pre-commit-install
1+
.PHONY: help dev dev-api dev-web build embed-copy test lint fmt ci clean web-install web-dev web-build migrate-up migrate-down migrate-status sqlc-generate openapi-validate openapi-check-frontend docker-build docker-up docker-down pre-commit-install
22

33
GO_LDFLAGS = -X github.com/karnstack/tempo/internal/version.Version=$(shell git rev-parse --short HEAD 2>/dev/null || echo dev)
44

@@ -16,7 +16,7 @@ MISE := $(shell \
1616
elif [ -x /opt/homebrew/bin/mise ]; then echo /opt/homebrew/bin/mise; \
1717
fi)
1818

19-
dev: ## Run Go (air) + Vite dev servers concurrently
19+
dev: migrate-up ## Run Go (air) + Vite dev servers concurrently
2020
@[ -n "$(MISE)" ] || (echo "install mise: https://mise.jdx.dev/installing-mise.html" && exit 1)
2121
@echo " Go → http://localhost:4811"
2222
@echo " Vite → http://localhost:4810 (proxies /api → :4811)"
@@ -27,6 +27,17 @@ dev: ## Run Go (air) + Vite dev servers concurrently
2727
$(MISE) exec -- pnpm -C web dev & \
2828
wait
2929

30+
dev-api: migrate-up ## Run only the Go API (via air). Use under portless.
31+
@[ -n "$(MISE)" ] || (echo "install mise: https://mise.jdx.dev/installing-mise.html" && exit 1)
32+
@echo " Go → http://localhost:4811 (override via PORT or TEMPO_LISTEN)"
33+
@$(MISE) exec -- air
34+
35+
dev-web: ## Run only the Vite dev server. Use under portless.
36+
@[ -n "$(MISE)" ] || (echo "install mise: https://mise.jdx.dev/installing-mise.html" && exit 1)
37+
@echo " Vite → http://localhost:4810 (override via PORT)"
38+
@echo " /api proxy → $${VITE_API_TARGET:-http://localhost:4811}"
39+
@$(MISE) exec -- pnpm -C web dev
40+
3041
build: web-build embed-copy ## Build SPA, copy into Go embed dir, build binary
3142
go build -ldflags "$(GO_LDFLAGS)" -o tempo ./cmd/tempo
3243

@@ -66,13 +77,13 @@ web-build: ## Build SPA into web/dist
6677
pnpm -C web build
6778

6879
migrate-up: ## Apply all pending DB migrations
69-
go run ./cmd/migrate up
80+
@$(MISE) exec -- go run ./cmd/migrate up
7081

7182
migrate-down: ## Roll back the latest DB migration
72-
go run ./cmd/migrate down
83+
@$(MISE) exec -- go run ./cmd/migrate down
7384

7485
migrate-status: ## Show migration status
75-
go run ./cmd/migrate status
86+
@$(MISE) exec -- go run ./cmd/migrate status
7687

7788
sqlc-generate: ## Regenerate sqlc-typed query bindings
7889
@command -v sqlc >/dev/null || (echo "install sqlc via 'mise install' (pinned in .mise.toml) or 'go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.31.1'" && exit 1)

0 commit comments

Comments
 (0)