From c74573c85045ec0ab95325725e9582efd62be931 Mon Sep 17 00:00:00 2001 From: XOF Date: Mon, 15 Dec 2025 04:03:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Makefile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..94ffc9b --- /dev/null +++ b/Makefile @@ -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"