切换并初始化新的生产服务器 #22

Merged
WuYongJie merged 1 commits from fix/WuYongJie-new-production-server into main 2026-08-10 10:57:15 +08:00
5 changed files with 14 additions and 14 deletions

View File

@ -106,10 +106,10 @@
### 8.2 服务器红线
- 当前服务器只有 2GB 内存,只负责运行容器、健康检查和镜像切换。
- 当前生产服务器约有 16GB 内存,仍只负责运行容器、健康检查和镜像切换。
- 严禁在服务器执行 `docker build`、`docker compose build`、`npm install`、`npm run production`、`composer install` 或其他源码构建命令。
- `compose.jiangling.yml` 不得出现 `build:`;服务器只能运行开发机已经构建并上传的 `caiwu_akaunting:<commit>` 镜像。
- 生产访问地址固定为 `https://118.196.84.79`(不附加端口);宿主机 Nginx 监听 `80/443`,HTTP 自动跳转 HTTPS,应用容器仅绑定 `127.0.0.1:18088`。
- 生产访问地址固定为 `https://218.93.190.75`(不附加端口);宿主机 Nginx 监听 `80/443`,HTTP 自动跳转 HTTPS,应用容器仅绑定 `127.0.0.1:18088`。
- HTTPS 使用 Let’s Encrypt 短期 IP 证书,服务器定时器每 8 小时检查续期;证书、私钥和 ACME 账户不得进入 Git 或应用镜像。
- `mariadb:11.4` 运行镜像由开发机缓存并仅随首次初始化全量包上传,服务器不得在发布时临时访问 Docker Hub。
- 日常发布必须通过只监听 `127.0.0.1` 的服务器本机 Registry 和 SSH 隧道传输,仅上传 Registry 中不存在的镜像层;禁止每次上传完整 `docker save` 压缩包。

View File

@ -1,7 +1,7 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 118.196.84.79;
server_name 218.93.190.75;
client_max_body_size 12m;

View File

@ -1,7 +1,7 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 118.196.84.79;
server_name 218.93.190.75;
location ^~ /.well-known/acme-challenge/ {
root /var/www/letsencrypt;
@ -16,7 +16,7 @@ server {
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name 118.196.84.79;
server_name 218.93.190.75;
ssl_certificate /etc/letsencrypt/live/caiwuxitong-ip/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/caiwuxitong-ip/privkey.pem;

View File

@ -13,7 +13,7 @@ if [ "$(id -u)" -ne 0 ]; then
exit 1
fi
if [ "$SERVER_IP" != "118.196.84.79" ]; then
if [ "$SERVER_IP" != "218.93.190.75" ]; then
echo "Refusing to configure an unexpected server IP: $SERVER_IP" >&2
exit 1
fi

View File

@ -22,7 +22,7 @@
任务分支开发 -> 本机验证 -> PR -> 任务 Codex 独立自审 -> 合并并验证 main
-> 开发机复用缓存构建镜像
-> 经 SSH 隧道只上传变化的镜像层
-> 2GB 服务器只拉取本机 Registry 并切换镜像
-> 生产服务器只拉取本机 Registry 并切换镜像
-> 本机后端检查 + 公网 HTTPS 验收
-> 保留当前与上一个镜像,清理其余本项目产物
```
@ -68,7 +68,7 @@
```powershell
.\scripts\deploy-from-workstation.ps1 `
-Server 118.196.84.79 `
-Server 218.93.190.75 `
-KeyPath "C:\Users\你的用户名\.ssh\caiwu.pem" `
-BootstrapServer
```
@ -76,7 +76,7 @@
初始化脚本会:
- 使用服务器现有 Ubuntu 安全更新源安装并启动 Docker 与 Compose;
- 为 2GB 服务器增加 2GB swap(交换空间),仅用于运行时缓冲;
- 服务器未配置 swap 时增加 2GB 交换空间,仅用于运行时缓冲;
- 创建 `/opt/caiwuxitong/runtime/.env`;
- 在服务器本地生成数据库密码和 Laravel `APP_KEY`,不会打印出来;
- 创建持久化数据库卷和运行文件卷;运行文件卷继续保存缓存、临时文件和可回滚的旧上传原件。
@ -88,14 +88,14 @@
```powershell
.\scripts\deploy-from-workstation.ps1 `
-Server 118.196.84.79 `
-Server 218.93.190.75 `
-KeyPath "C:\Users\你的用户名\.ssh\caiwu.pem" `
-ConfigureHttps
```
该步骤在服务器安装轻量 Nginx 和独立 Certbot 环境,为公网 IP 申请 Let’s Encrypt 短期证书,并启用每 8 小时检查一次的自动续期。服务器仍不构建任何应用源码或镜像。
首次打开 `https://118.196.84.79` 后,由负责人或指定人员在网页安装向导中设置管理员账号和密码。
首次打开 `https://218.93.190.75` 后,由负责人或指定人员在网页安装向导中设置管理员账号和密码。
## 5. 日常正式发布
@ -106,7 +106,7 @@ git switch main
git pull --ff-only
.\scripts\deploy-from-workstation.ps1 `
-Server 118.196.84.79 `
-Server 218.93.190.75 `
-KeyPath "C:\Users\你的用户名\.ssh\caiwu.pem"
```
@ -144,7 +144,7 @@ git pull --ff-only
```powershell
.\scripts\deploy-from-workstation.ps1 `
-Server 118.196.84.79 `
-Server 218.93.190.75 `
-KeyPath "C:\Users\你的用户名\.ssh\caiwu.pem" `
-AllowMigrations
```
@ -368,7 +368,7 @@ php artisan system-database:reencrypt-upstream-passwords --apply
- 发布分支和完整 Git SHA;
- 镜像标签;
- 服务器 `caiwu_app`、`caiwu_db` 状态;
- `https://118.196.84.79` 的实际返回结果和证书有效期;
- `https://218.93.190.75` 的实际返回结果和证书有效期;
- 是否执行数据库迁移;
- 本地临时包是否删除;
- 本地/服务器保留了几个本项目镜像;