🚀 deploy(build): 新增一键部署脚本与构建工具链
- 新增 deploy.sh:编译部署、systemd/Nginx 初始化、软链接版本管理与交互式回滚、部署后 /healthz 健康自检、certbot 自动申请 HTTPS 证书与续期重载 Hook - 新增 .deploy.env.example 部署配置模板,.deploy.env(不入库)覆盖脚本默认值,路径默认由 APP_NAME 派生,CERT_EMAIL 默认 admin@域名 - 新增 Makefile:build / build-linux 交叉编译 / test(含 go vet)/ clean - main.go 新增 Version/BuildTime 变量,使 -ldflags -X 注入生效并在启动日志打印 - systemd 工作目录改为代码目录,修复 config.yaml/.env/cache.db 相对路径加载失败 - .gitignore 忽略 .deploy.env 与 fanqie-* 编译产物;README 新增部署章节与 HTTPS 说明
This commit is contained in:
1 parent
6a473aea3e
commit
7da9184937
6 files changed
+506
-1
No files matched your search
@@ -0,0 +1,42 @@
|
||||
# ============================================================
|
||||
# 部署配置模板(deploy.sh 使用)
|
||||
#
|
||||
# 使用方法(在服务器上):
|
||||
# cp .deploy.env.example .deploy.env && vi .deploy.env
|
||||
#
|
||||
# 说明:
|
||||
# - .deploy.env 不入库(.gitignore 已忽略),只写要覆盖的项
|
||||
# - 路径类默认值由 APP_NAME 派生(如 /opt/${APP_NAME}/bin),改 APP_NAME 即全部跟随
|
||||
# - 应用环境变量固定读取 ${SRC_DIR}/.env(模板见 .env.example,敏感密码放那里)
|
||||
# ============================================================
|
||||
|
||||
# ---------- 应用信息 ----------
|
||||
# APP_NAME="fanqie"
|
||||
# APP_DESC="番茄小说api接口"
|
||||
|
||||
# ---------- 运行用户 ----------
|
||||
# 留空 = 执行 deploy.sh 的当前用户
|
||||
RUN_USER=""
|
||||
|
||||
# ---------- 路径 ----------
|
||||
# 代码目录,同时也是服务的工作目录(config/config.yaml、.env、cache.db 都在这里)
|
||||
SRC_DIR="/root/code/novel/fanqie-go"
|
||||
|
||||
# 以下路径默认由 APP_NAME 派生,一般无需修改:
|
||||
# BIN_DIR="/opt/fanqie/bin" # 默认 /opt/${APP_NAME}/bin
|
||||
# SERVICE_FILE="/etc/systemd/system/fanqie.service" # 默认 /etc/systemd/system/${APP_NAME}.service
|
||||
# NGINX_CONF="/etc/nginx/conf.d/fanqie.conf" # 默认 /etc/nginx/conf.d/${APP_NAME}.conf
|
||||
|
||||
# ---------- 网络 ----------
|
||||
# APP_PORT="40180"
|
||||
# DOMAIN="fq.20010117.xyz"
|
||||
|
||||
# ---------- 证书 ----------
|
||||
# Certbot 申请证书的邮箱(默认 admin@${DOMAIN}),用于接收过期提醒
|
||||
# CERT_EMAIL="you@example.com"
|
||||
|
||||
# ---------- 编译 ----------
|
||||
# BUILD_TARGET="./cmd/fanqie"
|
||||
|
||||
# ---------- 其他 ----------
|
||||
# KEEP_VERSIONS=5
|
||||
Reference in new issue
Block a user