# ULFlow Golang Starter Kit Makefile # Provides common commands for development, testing, and deployment # Load environment variables from .env file ifneq (,$(wildcard ./.env)) include .env export endif .PHONY: help init dev test lint build clean docker-build docker-run docker-clean docker-prune docker-compose-up docker-compose-down docker-compose-prod-up docker-compose-prod-down ci setup-git all # Default target executed when no arguments are given to make. default: help # Show help message for all Makefile commands help: @echo "ULFlow Golang Starter Kit" @echo "" @echo "Usage:" @echo " make " @echo "" @echo "Targets:" @echo " init - Initialize project dependencies and tools" @echo " dev - Start development server with hot reload (Air Tomb)" @echo " test - Run all tests" @echo " lint - Run linters and code quality tools" @echo " build - Build the application binary" @echo " clean - Clean temporary files, build artifacts, and cache" @echo " docker-build - Build Docker image" @echo " docker-run - Run application in Docker container" @echo " docker-clean - Remove project Docker containers" @echo " docker-prune - Remove all unused Docker resources" @echo " docker-compose-up - Start all services with Docker Compose for local development" @echo " docker-compose-down - Stop all services started with Docker Compose" @echo " docker-compose-prod-up - Start all services with Docker Compose for production" @echo " docker-compose-prod-down - Stop all production services" @echo " ci - Run CI workflow locally" @echo " setup-git - Configure Git with commit message template and hooks" @echo " all - Run lint, test, and build" # Initialize project dependencies and tools init: @echo "Installing project dependencies and tools..." go mod tidy go install github.com/cosmtrek/air@latest go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest @echo "Creating necessary directories..." mkdir -p tmp mkdir -p logs @echo "Copying .env file if not exists..." @if not exist .env ( if exist templates\.env.example ( copy templates\.env.example .env @echo "Created .env file from example" ) else ( @echo "Warning: templates/.env.example not found, skipping .env creation" ) ) else ( @echo ".env file already exists, skipping" ) @echo "Initialization complete!" # Start development server with hot reload dev: @echo "Starting development server with Air Tomb..." air # Run all tests test: @echo "Running tests..." go test -v -cover ./... # Run linters and code quality tools lint: @echo "Running linters..." golangci-lint run ./... # Build the application binary build: @echo "Building application..." go build -o bin/app cmd/app/main.go # Clean temporary files, build artifacts, and cache clean: @echo "Cleaning project..." if exist tmp rmdir /s /q tmp if exist bin rmdir /s /q bin if exist logs rmdir /s /q logs go clean -cache -testcache -modcache @echo "Project cleaned!" # Build Docker image docker-build: @echo "Building Docker image..." docker build -t ulflow-starter-kit:latest . # Run application in Docker container docker-run: @echo "Running application in Docker container..." @if not exist .env ( @echo "Warning: .env file not found. Running with default environment variables..." docker run -p 3000:3000 ulflow-starter-kit:latest ) else ( docker run -p 3000:3000 --env-file .env ulflow-starter-kit:latest ) # Run Docker Compose for local development docker-compose-up: @echo "Starting all services with Docker Compose for local development..." docker-compose up -d @echo "Services started! API is available at http://localhost:3000" # Stop Docker Compose services for local development docker-compose-down: @echo "Stopping all development services..." docker-compose down # Run Docker Compose for production docker-compose-prod-up: @echo "Starting all services with Docker Compose for production..." docker-compose -f docker-compose.prod.yml up -d @echo "Production services started! API is available at http://localhost:3000" # Stop Docker Compose services for production docker-compose-prod-down: @echo "Stopping all production services..." docker-compose -f docker-compose.prod.yml down # Setup Git configuration setup-git-hooks: @echo "Setting up Git hooks..." git config --local commit.template .gitea/commit-template.txt if not exist .git/hooks mkdir .git/hooks copy /Y .gitea\hooks\pre-commit .git\hooks\ >nul copy /Y .gitea\hooks\prepare-commit-msg .git\hooks\ >nul git config --local core.hooksPath .git/hooks @echo "Git setup complete!" # Create git message template setup-git-message: @echo "Creating Git commit message template..." if not exist .gitea mkdir .gitea mkdir -p .gitea echo "# : \n\n# \n\n#