|
| 1 | +# Uptime Kuma on Fly.io |
| 2 | + |
| 3 | +This project provides a customized Docker image for deploying [Uptime Kuma](https://github.com/louislam/uptime-kuma) (v2) on [Fly.io](https://fly.io/). It is enhanced with a process manager, cron scheduler, backup utilities, and a reverse proxy to provide a robust monitoring solution. |
| 4 | + |
| 5 | +## ✨ Features |
| 6 | + |
| 7 | +- **Uptime Kuma v2**: The latest version of the fancy self-hosted monitoring tool. |
| 8 | +- **Overmind**: A process manager to handle multiple processes (Uptime Kuma, Caddy, Supercronic) within the single container. |
| 9 | +- **Caddy**: A powerful, enterprise-ready, open source web server with automatic HTTPS, acting as a reverse proxy. |
| 10 | +- **Supercronic**: A cron-compatible job runner for containers, used for scheduling backups. |
| 11 | +- **Restic**: A fast, secure, and efficient backup program. |
| 12 | +- **Fly.io Ready**: Optimized configuration for deployment on Fly.io. |
| 13 | + |
| 14 | +## 🚀 Deployment Guide |
| 15 | + |
| 16 | +Follow these steps to deploy your own instance on Fly.io. |
| 17 | + |
| 18 | +### Prerequisites |
| 19 | + |
| 20 | +- A [Fly.io](https://fly.io/) account. |
| 21 | +- [flyctl](https://fly.io/docs/hands-on/install-flyctl/) installed on your machine. |
| 22 | + |
| 23 | +### Steps |
| 24 | + |
| 25 | +1. **Login to Fly.io** |
| 26 | + ```bash |
| 27 | + fly auth login |
| 28 | + ``` |
| 29 | + |
| 30 | +2. **Create the Application** |
| 31 | + Replace `uptime-kuma` with your desired unique app name. |
| 32 | + ```bash |
| 33 | + fly apps create uptime-kuma |
| 34 | + ``` |
| 35 | + |
| 36 | +3. **Configure Secrets** |
| 37 | + Create a `.env` file with your sensitive configuration (e.g., Restic passwords, S3 credentials) and import them. |
| 38 | + ```bash |
| 39 | + # Example .env content |
| 40 | + # RESTIC_PASSWORD=your_secure_password |
| 41 | + # AWS_ACCESS_KEY_ID=... |
| 42 | + # AWS_SECRET_ACCESS_KEY=... |
| 43 | + |
| 44 | + cat .env | fly secrets import |
| 45 | + ``` |
| 46 | + |
| 47 | +4. **Create Persistent Storage** |
| 48 | + Create a volume to store Uptime Kuma's database and data. |
| 49 | + ```bash |
| 50 | + fly volumes create app_data --size 1 |
| 51 | + ``` |
| 52 | +
|
| 53 | +5. **Deploy** |
| 54 | + Deploy the application using the configuration in `fly.toml`. |
| 55 | + ```bash |
| 56 | + fly deploy |
| 57 | + ``` |
| 58 | +
|
| 59 | +## ⚙️ Configuration |
| 60 | +
|
| 61 | +### Environment Variables |
| 62 | +
|
| 63 | +The following environment variables can be set in your `.env` file or via `fly secrets set`: |
| 64 | +
|
| 65 | +- `TZ`: Timezone (default: `Asia/Shanghai`). |
| 66 | +- `RESTIC_REPOSITORY`: Restic repository location (e.g., `s3:https://s3.amazonaws.com/bucket_name`). |
| 67 | +- `RESTIC_PASSWORD`: Password for the Restic repository. |
| 68 | +- `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY`: Credentials for S3 storage if used for backups. |
| 69 | +
|
| 70 | +### Config Files |
| 71 | +
|
| 72 | +- **`config/Caddyfile`**: Configuration for the Caddy web server. |
| 73 | +- **`config/crontab`**: Cron schedule for scheduled tasks (e.g., backups). |
| 74 | +- **`config/Procfile`**: Process definitions for Overmind. |
| 75 | +
|
| 76 | +## 🛡️ Backup & Restore |
| 77 | +
|
| 78 | +This image includes `restic` for backups. A helper script is available at `/restic.sh`. |
| 79 | +
|
| 80 | +### Automatic Backups |
| 81 | +Backups are scheduled via `config/crontab`. By default, check the `config/crontab` file to see the schedule. |
| 82 | +
|
| 83 | +### Manual Operations |
| 84 | +
|
| 85 | +You can run commands inside the container using `fly ssh console`. |
| 86 | +
|
| 87 | +**Trigger a Backup:** |
| 88 | +```bash |
| 89 | +/restic.sh backup |
1 | 90 | ``` |
2 | | -# 1️⃣ Log in to your Fly.io account (opens browser authentication) |
3 | | -fly auth login |
4 | 91 |
|
5 | | -# 2️⃣ Create the Fly.io application (app name: uptime-kuma) |
6 | | -fly apps create uptime-kuma |
| 92 | +**List Snapshots:** |
| 93 | +```bash |
| 94 | +/restic.sh snapshots |
| 95 | +``` |
| 96 | +
|
| 97 | +**Restore:** |
| 98 | +```bash |
| 99 | +/restic.sh restore <snapshot-id> |
| 100 | +``` |
7 | 101 |
|
8 | | -# 3️⃣ Import all environment variables from .env into Fly Secrets |
9 | | -cat .env | fly secrets import |
| 102 | +## 🛠️ Local Development |
10 | 103 |
|
11 | | -# 4️⃣ Create a persistent volume named app_data with 1GB storage |
12 | | -fly volumes create app_data --size 1 |
| 104 | +To build and run the image locally: |
13 | 105 |
|
14 | | -# 5️⃣ Deploy the current project to Fly.io (based on fly.toml configuration) |
15 | | -fly deploy |
| 106 | +```bash |
| 107 | +# Build the image |
| 108 | +docker build -t uptime-kuma-custom . |
16 | 109 |
|
17 | | -# 6️⃣ Open an SSH console into the running Fly.io instance for debugging |
18 | | -fly ssh console |
| 110 | +# Run the container |
| 111 | +docker run -d \ |
| 112 | + -p 80:80 \ |
| 113 | + -v $(pwd)/data:/app/data \ |
| 114 | + --env-file .env \ |
| 115 | + uptime-kuma-custom |
19 | 116 | ``` |
0 commit comments