44 lines
1.1 KiB
Makefile
44 lines
1.1 KiB
Makefile
.PHONY: help setup run dev build fmt migrate-up migrate-down migrate-status migrate-create db-reset generate docker-build
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
help: ## List available targets
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'
|
|
|
|
setup: ## Copy .env, tidy modules, enable git hooks
|
|
cp -n .env.example .env || true
|
|
go mod tidy
|
|
git config core.hooksPath .githooks
|
|
|
|
run: ## Run the server
|
|
go run ./cmd
|
|
|
|
dev: ## Run the server with live reload (air)
|
|
air
|
|
|
|
build: ## Build the server binary to ./tmp/main
|
|
go build -o ./tmp/main ./cmd
|
|
|
|
fmt: ## Format all Go files
|
|
gofmt -l -w .
|
|
|
|
migrate-up: ## Apply all pending migrations
|
|
./scripts/goose.sh up
|
|
|
|
migrate-down: ## Roll back the last migration
|
|
./scripts/goose.sh down
|
|
|
|
migrate-status: ## Show migration status
|
|
./scripts/goose.sh status
|
|
|
|
migrate-create: ## Create a new migration (name=add_widgets)
|
|
./scripts/goose-create.sh $(name)
|
|
|
|
db-reset: ## Wipe the database and reapply all migrations
|
|
./scripts/reset-db.sh
|
|
|
|
generate: ## Run sqlc codegen
|
|
sqlc generate
|
|
|
|
docker-build: ## Build the Docker image
|
|
docker build -t go-backend .
|