Files

65 lines
1.7 KiB
Makefile
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# VPN 管理平台 - Makefile // Logan.Li
# 提供常用开发命令的快捷方式(与 run.sh 对应)
.PHONY: help build build-frontend build-binary run dev stop restart status clean
# 默认显示帮助
help:
@echo "VPN 管理平台 - 可用命令:"
@echo ""
@echo " make build - 全量构建(前端 + 后端单二进制)"
@echo " make build-frontend - 仅构建前端(输出到 backend/dist)"
@echo " make build-binary - 仅编译 Go 二进制(需先构建前端)"
@echo " make run - 构建并后台运行单二进制"
@echo " make dev - 开发模式(前后端分离)"
@echo " make stop - 停止所有服务"
@echo " make restart - 重启服务"
@echo " make status - 查看服务状态"
@echo " make clean - 清理构建产物"
@echo ""
# 构建前端
build-frontend:
@echo "🔨 构建前端..."
cd frontend && npm install && npm run build
# 编译 Go 二进制
build-binary:
@echo "🔨 编译 Go 单二进制..."
@if [ ! -d backend/dist ]; then mkdir -p backend/dist && echo '<!doctype html><html><body>请先构建前端</body></html>' > backend/dist/index.html; fi
go build -ldflags="-s -w" -o opsx-vpn ./backend
# 全量构建
build: build-frontend build-binary
@echo "✅ 全量构建完成: opsx-vpn"
# 构建并运行
run:
./run.sh run
# 开发模式
dev:
./run.sh dev
# 停止服务
stop:
./run.sh stop
# 重启服务
restart:
./run.sh restart
# 查看状态
status:
./run.sh status
# 清理
clean:
@echo "🧹 清理构建产物..."
rm -f opsx-vpn
rm -rf backend/dist
rm -rf frontend/node_modules
rm -rf frontend/dist
rm -f logs/*.log
@echo "🧹 清理完成"