部署到 Google Cloud
在 Google Cloud Compute Engine 或 Cloud Run 上部署 nostrfy — 分步说明,含 systemd、TLS 和缩容到零的注意事项。
选项:Compute Engine(VM,推荐)或 Cloud Run (容器)。
选项 1:Compute Engine(推荐)
- 创建 VM:Ubuntu 24.04 LTS(或 Debian),
e2-small(2 GB) 起步足够。选择离用户近的区域。 - 防火墙规则:允许入站 TCP
8080(以及443用于 TLS)。在 Network → Firewall 下,用你分配给 VM 的目标标签创建规则。 - SSH 登录(控制台的 SSH 按钮即可)并按照通用 VPS 指南操作:
sh
curl -fsSL https://raw.githubusercontent.com/iqbqioza/nostrfy/main/install.sh | sh
sudo mkdir -p /etc/nostrfy
sudo curl -fsSL -o /etc/nostrfy/nostrfy.toml \
https://raw.githubusercontent.com/iqbqioza/nostrfy/main/deploy/nostrfy.toml
sudo nano /etc/nostrfy/nostrfy.toml # 设置 name、public_url、private_key
sudo curl -fsSL -o /etc/systemd/system/nostrfy.service \
https://raw.githubusercontent.com/iqbqioza/nostrfy/main/deploy/nostrfy.service
sudo systemctl daemon-reload
sudo systemctl enable --now nostrfy- 预留静态 IP(External IP → Reserve),使
public_url在 重启后仍然有效。 - 验证:
sh
curl http://<external-ip>:8080/health- 添加 TLS(
wss://)用 certbot + nginx(如 VPS 指南)或带托管证书的 GCP 负载均衡器。
选项 2:Cloud Run(容器)
Cloud Run 从仓库的 Dockerfile 构建(它会下载预编译的发布
二进制):
- 从 GitHub 仓库创建服务(或将镜像推送到 Artifact Registry)。
- 端口:将容器端口设置为
8080。 - 分配内存:至少 512 MB(LMDB + 异步运行时)。
- 持久存储:在
/data附加 Cloud Run 卷(filestore/gcsfuse) — LMDB 需要文件系统,因此在/data挂载 GCS FUSE 可实现持久化。 - TLS:Cloud Run 自动提供
https://— 设置relay.public_url = "wss://<service>.a.run.app"(或你的自定义域)。