go-mad/Makefile

91 lines
2.3 KiB
Makefile
Raw Normal View History

2026-10-07 15:17:40 +02:00
.PHONY: all build test vet fmt compose-up compose-down logs clean help web-dev
2026-10-04 16:20:07 +02:00
GO_VERSION ?= 1.27.1
BINARY_NAME ?= go-mad
BINARY_DIR ?= ./bin
WEB_DIR ?= web
DOCKER_BUILD ?= build
# Configuration defaults
GO_LOOSE_ADDR ?= http://localhost:8080
GO_MAD_ADDR ?= http://localhost:8080
## ---- Build ----
build: fmt vet ## Build the Go binary
@mkdir -p $(BINARY_DIR)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BINARY_DIR)/$(BINARY_NAME) ./cmd/$(BINARY_NAME)/main.go
## ---- Development ----
run: build ## Run the Go binary (requires postgres running)
2026-10-07 15:17:40 +02:00
@$(BINARY_DIR)/$(BINARY_NAME)
2026-10-04 16:20:07 +02:00
compose-up: ## Start docker compose (postgres + go-mad)
docker compose up --build -d
compose-down: ## Stop docker compose
docker compose down
compose-logs: ## View docker compose logs
docker compose logs -f
## ---- Code Quality ----
fmt: ## Format Go code
go fmt ./...
vet: ## Vet Go code
go vet ./...
test: ## Run Go unit tests
go test ./...
integration-test: ## Run integration tests (requires test database)
@test -n "$(GO_MAD_TEST_DATABASE_URL)" || (echo "GO_MAD_TEST_DATABASE_URL is required" && exit 1)
go test ./... -run TestIntegration -v
## ---- Web Frontend ----
web-build: ## Build React frontend
2026-10-07 15:17:40 +02:00
cd web && npm install && npm run build
2026-10-04 16:20:07 +02:00
2026-10-07 15:17:40 +02:00
web-dev: ## Start the go-mad application with Docker Compose
@docker compose up --build -d
2026-10-04 16:20:07 +02:00
## ---- Docker ----
docker-build: ## Build docker image
docker build -t $(BINARY_NAME):latest .
docker-push: ## Push docker image
docker push $(BINARY_NAME):latest
## ---- Cleanup ----
clean: ## Remove build artifacts
rm -rf /out
rm -rf $(WEB_DIR)/dist
rm -rf $(WEB_NODE_MODULES)
help: ## Show this help message
@echo "Usage: make <target>"
@echo ""
@echo "Build targets:"
@echo " build Build the Go binary"
2026-10-07 15:17:40 +02:00
@echo " run Run the Go binary (requires postgres running)"
2026-10-04 16:20:07 +02:00
@echo " compose-up Start docker compose"
@echo " compose-down Stop docker compose"
@echo " compose-logs View docker compose logs"
@echo ""
2026-10-07 15:17:40 +02:00
@echo "Web frontend:"
@echo " web-build Build React frontend"
@echo " web-dev Start go-mad with docker compose"
2026-10-04 16:20:07 +02:00
@echo ""
@echo "Docker:"
@echo " docker-build Build docker image"
@echo " docker-push Push docker image"
@echo ""
@echo "Other:"
@echo " clean Remove build artifacts"
@echo " help Show this help message"