Files
blogging-cms/Makefile
T
nutshell9247 852613586f
CI/CD Pipeline / Test & Lint (push) Waiting to run
CI/CD Pipeline / Build Docker Image (push) Blocked by required conditions
CI/CD Pipeline / Security Scan (push) Waiting to run
first commit, mate!
2026-08-08 14:43:59 +08:00

85 lines
2.1 KiB
Makefile

.PHONY: help build run test clean docker-build docker-up docker-down fmt lint
# Variables
APP_NAME=blogging-cms
GO_VERSION=1.21
PORT=8080
help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
install-deps: ## Install Go dependencies
go mod download
go mod tidy
build: ## Build the application
CGO_ENABLED=0 GOOS=linux go build -o $(APP_NAME) .
run: ## Run the application locally
go run main.go
dev: install-deps ## Run in development mode with hot reload
which air > /dev/null || go install github.com/cosmtrek/air@latest
air
test: ## Run tests
go test -v -race -coverprofile=coverage.out ./...
test-coverage: test ## Run tests and display coverage
go tool cover -html=coverage.out
clean: ## Clean build artifacts
rm -f $(APP_NAME)
rm -f coverage.out
rm -rf dist/
fmt: ## Format code
gofmt -s -w .
go mod tidy
lint: ## Run linter
which golangci-lint > /dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run ./...
vet: ## Run go vet
go vet ./...
docker-build: ## Build Docker image
docker build -t $(APP_NAME):latest .
docker-up: ## Start Docker containers
docker-compose up -d
docker-down: ## Stop Docker containers
docker-compose down
docker-logs: ## View Docker logs
docker-compose logs -f app
docker-clean: ## Remove Docker containers and volumes
docker-compose down -v
docker-rebuild: docker-down docker-build docker-up ## Rebuild and restart containers
db-shell: ## Access MariaDB shell
docker-compose exec mariadb mysql -u cms_user -p blogging_cms
db-reset: ## Reset database (DANGEROUS!)
docker-compose exec mariadb mysql -u root -p -e "DROP DATABASE blogging_cms; CREATE DATABASE blogging_cms;"
setup: ## Complete setup for development
cp .env.example .env
go mod download
docker-compose up -d
@echo "Setup complete! Run 'make dev' to start developing."
update-deps: ## Update Go dependencies
go get -u ./...
go mod tidy
check: fmt vet lint ## Run all checks
all: clean install-deps build test ## Build and test
.DEFAULT_GOAL := help