72 lines
2.0 KiB
Makefile
72 lines
2.0 KiB
Makefile
|
|
.PHONY: run build test clean dev prod docker-build docker-run
|
||
|
|
|
||
|
|
# Development
|
||
|
|
dev:
|
||
|
|
@echo "🚀 Starting development server..."
|
||
|
|
GO_ENV=development go run main.go
|
||
|
|
|
||
|
|
# Production
|
||
|
|
prod:
|
||
|
|
@echo "🚀 Starting production server..."
|
||
|
|
GO_ENV=production go run main.go
|
||
|
|
|
||
|
|
# Build
|
||
|
|
build:
|
||
|
|
@echo "🔨 Building binary..."
|
||
|
|
go build -o cv-server -ldflags="-s -w" .
|
||
|
|
@echo "✓ Binary created: ./cv-server"
|
||
|
|
|
||
|
|
# Run built binary
|
||
|
|
run: build
|
||
|
|
./cv-server
|
||
|
|
|
||
|
|
# Test
|
||
|
|
test:
|
||
|
|
@echo "🧪 Testing endpoints..."
|
||
|
|
@echo "\n1. Health check:"
|
||
|
|
@curl -s http://localhost:8080/health | jq .
|
||
|
|
@echo "\n2. English CV (first 50 chars):"
|
||
|
|
@curl -s "http://localhost:8080/?lang=en" | head -c 50
|
||
|
|
@echo "\n\n3. Spanish CV content (first 50 chars):"
|
||
|
|
@curl -s "http://localhost:8080/cv?lang=es" | head -c 50
|
||
|
|
@echo "\n\n4. Security headers:"
|
||
|
|
@curl -I http://localhost:8080/ 2>&1 | grep -E "^(X-|Content-Security)"
|
||
|
|
@echo "\n✓ All tests complete"
|
||
|
|
|
||
|
|
# Test error handling
|
||
|
|
test-errors:
|
||
|
|
@echo "🧪 Testing error handling..."
|
||
|
|
@echo "\n1. Invalid language:"
|
||
|
|
@curl -i "http://localhost:8080/?lang=invalid" 2>&1 | head -15
|
||
|
|
@echo "\n2. Error logging check"
|
||
|
|
@echo "✓ Error tests complete"
|
||
|
|
|
||
|
|
# Clean
|
||
|
|
clean:
|
||
|
|
@echo "🧹 Cleaning build artifacts..."
|
||
|
|
rm -f cv-server
|
||
|
|
@echo "✓ Clean complete"
|
||
|
|
|
||
|
|
# Docker
|
||
|
|
docker-build:
|
||
|
|
@echo "🐳 Building Docker image..."
|
||
|
|
docker build -t cv-server:latest .
|
||
|
|
@echo "✓ Docker image built"
|
||
|
|
|
||
|
|
docker-run:
|
||
|
|
@echo "🐳 Running Docker container..."
|
||
|
|
docker run -p 8080:8080 cv-server:latest
|
||
|
|
|
||
|
|
# Help
|
||
|
|
help:
|
||
|
|
@echo "Available commands:"
|
||
|
|
@echo " make dev - Run in development mode (hot-reload enabled)"
|
||
|
|
@echo " make prod - Run in production mode"
|
||
|
|
@echo " make build - Build production binary"
|
||
|
|
@echo " make run - Build and run binary"
|
||
|
|
@echo " make test - Test all endpoints"
|
||
|
|
@echo " make test-errors - Test error handling"
|
||
|
|
@echo " make clean - Remove build artifacts"
|
||
|
|
@echo " make docker-build - Build Docker image"
|
||
|
|
@echo " make docker-run - Run Docker container"
|