chore: add install/build targets and split dev/prod server commands
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
094c8953b6
commit
6e96e72b3e
@@ -2,32 +2,61 @@
|
|||||||
-include .env
|
-include .env
|
||||||
export
|
export
|
||||||
|
|
||||||
.PHONY: docker-up docker-down migrate-up migrate-down \
|
.PHONY: install build \
|
||||||
run-backend run-frontend test test-coverage lint seed
|
docker-up docker-down migrate-up migrate-down \
|
||||||
|
run-backend run-frontend \
|
||||||
|
dev-backend dev-frontend \
|
||||||
|
test test-coverage lint seed
|
||||||
|
|
||||||
|
## ── Setup ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
# Install all dependencies: Go CLI tools, Go modules, Node packages.
|
||||||
|
install:
|
||||||
|
go install github.com/pressly/goose/v3/cmd/goose@latest
|
||||||
|
go install github.com/air-verse/air@latest
|
||||||
|
cd backend && go mod download
|
||||||
|
cd frontend && npm ci
|
||||||
|
|
||||||
|
# Build the Go binary and the Next.js production bundle.
|
||||||
|
build:
|
||||||
|
mkdir -p backend/bin
|
||||||
|
cd backend && go build -o bin/api ./cmd/api
|
||||||
|
cd frontend && npm run build
|
||||||
|
|
||||||
|
## ── Infrastructure ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
## Infrastructure
|
|
||||||
docker-up:
|
docker-up:
|
||||||
docker compose up -d postgres redis
|
docker compose up -d postgres redis
|
||||||
|
|
||||||
docker-down:
|
docker-down:
|
||||||
docker compose down
|
docker compose down
|
||||||
|
|
||||||
## Migrations (requires goose: go install github.com/pressly/goose/v3/cmd/goose@latest)
|
|
||||||
migrate-up:
|
migrate-up:
|
||||||
PATH=$$HOME/go/bin:$$PATH goose -dir migrations postgres "$(DATABASE_URL)" up
|
PATH=$$HOME/go/bin:$$PATH goose -dir migrations postgres "$(DATABASE_URL)" up
|
||||||
|
|
||||||
migrate-down:
|
migrate-down:
|
||||||
PATH=$$HOME/go/bin:$$PATH goose -dir migrations postgres "$(DATABASE_URL)" down
|
PATH=$$HOME/go/bin:$$PATH goose -dir migrations postgres "$(DATABASE_URL)" down
|
||||||
|
|
||||||
## Development servers
|
## ── Production servers (require `make build` first) ─────────────────────────
|
||||||
|
|
||||||
|
# Run the compiled Go binary.
|
||||||
run-backend:
|
run-backend:
|
||||||
|
cd backend && ./bin/api
|
||||||
|
|
||||||
|
# Run the Next.js production server on port 3001.
|
||||||
|
run-frontend:
|
||||||
|
cd frontend && env -u PORT npx next start -p 3001
|
||||||
|
|
||||||
|
## ── Development servers (hot reload) ────────────────────────────────────────
|
||||||
|
|
||||||
|
dev-backend:
|
||||||
cd backend && PATH=$$HOME/go/bin:$$PATH air
|
cd backend && PATH=$$HOME/go/bin:$$PATH air
|
||||||
|
|
||||||
# PORT is exported from .env (backend uses it); unset it so Next.js defaults to 3000.
|
dev-frontend:
|
||||||
run-frontend:
|
|
||||||
cd frontend && env -u PORT npm run dev
|
cd frontend && env -u PORT npm run dev
|
||||||
|
|
||||||
## Testing
|
## ── Testing ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
test:
|
test:
|
||||||
cd backend && go test ./... && cd ../frontend && npm test -- --passWithNoTests
|
cd backend && go test ./... && cd ../frontend && npm test -- --passWithNoTests
|
||||||
|
|
||||||
@@ -35,11 +64,13 @@ test-coverage:
|
|||||||
cd backend && go test -coverprofile=coverage.out ./... && go tool cover -html=coverage.out -o coverage.html
|
cd backend && go test -coverprofile=coverage.out ./... && go tool cover -html=coverage.out -o coverage.html
|
||||||
@echo "Coverage report: backend/coverage.html"
|
@echo "Coverage report: backend/coverage.html"
|
||||||
|
|
||||||
## Dev seed (local DB only — never run against production)
|
## ── Dev seed (local DB only — never run against production) ──────────────────
|
||||||
|
|
||||||
seed:
|
seed:
|
||||||
cd backend && go run ./cmd/seed
|
cd backend && go run ./cmd/seed
|
||||||
|
|
||||||
## Linting
|
## ── Linting ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
cd backend && golangci-lint run ./...
|
cd backend && golangci-lint run ./...
|
||||||
cd frontend && npx tsc --noEmit && npx eslint .
|
cd frontend && npx tsc --noEmit && npx eslint .
|
||||||
|
|||||||
Reference in New Issue
Block a user