initial commit
This commit is contained in:
commit
ebd5bb09fd
30 changed files with 1920 additions and 0 deletions
98
Makefile
Normal file
98
Makefile
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
.PHONY: all build test vet fmt compose-up compose-down logs clean help
|
||||
|
||||
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)
|
||||
@$(BINARY_NAME)
|
||||
|
||||
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
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
web-dev: ## Run React dev server
|
||||
npm install
|
||||
npm run dev
|
||||
|
||||
## ---- 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"
|
||||
@echo " run Run the Go binary"
|
||||
@echo " compose-up Start docker compose"
|
||||
@echo " compose-down Stop docker compose"
|
||||
@echo " compose-logs View docker compose logs"
|
||||
@echo ""
|
||||
@echo "Code quality:"
|
||||
@echo " fmt Format Go code"
|
||||
@echo " vet Vet Go code"
|
||||
@echo " test Run Go unit tests"
|
||||
@echo ""
|
||||
@echo "Docker:"
|
||||
@echo " docker-build Build docker image"
|
||||
@echo " docker-push Push docker image"
|
||||
@echo ""
|
||||
@echo "Web frontend:"
|
||||
@echo " web-build Build React frontend"
|
||||
@echo " web-dev Run React dev server"
|
||||
@echo ""
|
||||
@echo "Other:"
|
||||
@echo " clean Remove build artifacts"
|
||||
@echo " help Show this help message"
|
||||
Loading…
Add table
Add a link
Reference in a new issue