46 lines
981 B
Makefile
46 lines
981 B
Makefile
.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"
|