部署到 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"(或你的自訂網域)。