统一通知中心,让所有 homelab 服务(Watchtower、Alertmanager、Gitea 等)通过 ntfy 推送通知到手机/桌面。
| 服务 | 镜像 | 端口 | 用途 |
|---|---|---|---|
| ntfy | binwiederhier/ntfy:v2.11.0 |
80 (内部) | 主推送通知服务 |
| Gotify | gotify/server:2.5.0 |
80 (内部) | 备用推送服务 |
| Apprise | caronc/apprise:v1.1.6 |
8000 | 多平台通知路由 |
# 1. 创建配置目录
mkdir -p config/ntfy config/alertmanager
# 2. 启动服务
docker compose up -d
# 3. 测试推送
./scripts/notify.sh homelab-test "Test" "Hello from autarky-bot!" 3在 docker-compose.yml 中添加:
watchtower:
environment:
- WATCHTOWER_NOTIFICATIONS=ntfy
- WATCHTOWER_NOTIFICATION_URL=https://ntfy.${DOMAIN}/watchtower
- WATCHTOWER_NOTIFICATION_HTTP_HEADERS=Authorization: Bearer ${NTFY_TOKEN}已配置 config/alertmanager/alertmanager.yml,webhook receiver 指向 ntfy。
receivers:
- name: ntfy
webhook_configs:
- url: "https://ntfy.${DOMAIN}/homelab-alerts"
send_resolved: true- 进入 Gitea → 仓库 → Settings → Webhooks
- 添加 Webhook,URL:
https://ntfy.${DOMAIN}/gitea - Content type:
application/json - 选择触发事件
# configuration.yaml
notify:
- platform: rest
name: ntfy
resource: https://ntfy.${DOMAIN}/home-assistant
method: POST
headers:
Authorization: "Bearer ${NTFY_TOKEN}"- Settings → Notifications → 添加
- 类型:Webhook
- URL:
https://ntfy.${DOMAIN}/uptime-kuma - 添加 Header:
Title: {{monitorName}}
统一接口 scripts/notify.sh:
./scripts/notify.sh <topic> <title> <message> [priority] [tags]示例:
# 发送低级通知
./scripts/notify.sh backup "备份完成" "数据库备份成功" 2 floppy_disk
# 发送紧急告警
./scripts/notify.sh alerts "磁盘空间不足" "根分区已使用 95%" 5 warning- ntfy: 安装 ntfy App → 添加服务器
https://ntfy.${DOMAIN}→ 订阅 topic - Gotify: 安装 Gotify App → 连接服务器
https://gotify.${DOMAIN}
| 变量 | 必填 | 说明 |
|---|---|---|
DOMAIN |
✅ | 域名 |
TZ |
❌ | 时区,默认 Asia/Shanghai |
NTFY_TOKEN |
❌ | ntfy API token(启用认证时必填) |
GOTIFY_TOKEN |
❌ | Gotify app token |