添加 Makefile

This commit is contained in:
XOF
2025-12-15 04:03:07 +08:00
parent 41171519b9
commit c74573c850

45
Makefile Normal file
View File

@@ -0,0 +1,45 @@
.PHONY: init build docker-build docker-run clean test
# 初始化项目
init:
@echo "Initializing project..."
go mod init siteproxy || true
go get golang.org/x/net/html
go mod tidy
@echo "✓ Project initialized"
# 本地构建
build: init
@echo "Building binary..."
CGO_ENABLED=0 go build -ldflags="-s -w" -o siteproxy .
@echo "✓ Build complete: ./siteproxy"
# Docker 构建
docker-build:
@echo "Building Docker image..."
docker build -t siteproxy:latest .
@echo "✓ Docker image built"
# Docker 运行
docker-run: docker-build
@echo "Starting container..."
docker-compose up -d
@echo "✓ Container started"
@echo "Access at: http://localhost:8080"
# 清理
clean:
@echo "Cleaning..."
rm -f siteproxy siteproxy-*
docker-compose down 2>/dev/null || true
@echo "✓ Cleaned"
# 测试
test:
@echo "Running tests..."
go test -v -cover ./...
@echo "✓ Tests passed"
# 完整部署
deploy: init docker-build docker-run
@echo "✓ Deployment complete"