| 1 | # AiToEarn Docker Deployment Guide |
| 2 | |
| 3 | This guide helps you quickly deploy the complete AiToEarn application using Docker Compose. |
| 4 | |
| 5 | ## Architecture |
| 6 | |
| 7 | ``` |
| 8 | ┌──────────┐ |
| 9 | │ Nginx │ |
| 10 | │ :8080 │ |
| 11 | └────┬─────┘ |
| 12 | │ |
| 13 | ┌───────────────┼───────────────┐ |
| 14 | │ │ │ |
| 15 | ┌─────┴─────┐ ┌─────┴──────┐ ┌─────┴─────┐ |
| 16 | │ Web (FE) │ │ Server │ │ AI │ |
| 17 | │ :3000 │ │ :3002 │ │ :3010 │ |
| 18 | └────────────┘ └──────┬─────┘ └─────┬─────┘ |
| 19 | │ │ |
| 20 | ┌────────────┼──────────────┤ |
| 21 | │ │ │ |
| 22 | ┌────┴─────┐ ┌───┴────┐ ┌──────┴───┐ |
| 23 | │ MongoDB │ │ Redis │ │ RustFS │ |
| 24 | │ :27017 │ │ :6379 │ │ :9000/01 │ |
| 25 | └──────────┘ └────────┘ └──────────┘ |
| 26 | ``` |
| 27 | |
| 28 | | Service | Description | Port | |
| 29 | |---------|-------------|------| |
| 30 | | **Nginx** | Reverse proxy, unified entry | 8080 (public) | |
| 31 | | **aitoearn-web** | Next.js frontend | 3000 (internal) | |
| 32 | | **aitoearn-server** | NestJS main backend API | 3002 (internal) | |
| 33 | | **aitoearn-ai** | NestJS AI service | 3010 (internal) | |
| 34 | | **MongoDB** | Database | 27017 | |
| 35 | | **Redis** | Cache / Queue | 6379 | |
| 36 | | **RustFS** | S3-compatible object storage | 9000 (API) / 9001 (Console) | |
| 37 | |
| 38 | ## Prerequisites |
| 39 | |
| 40 | - **Docker**: 20.10+ |
| 41 | - **Docker Compose**: 2.0+ |
| 42 | - **System RAM**: 4GB+ recommended |
| 43 | - **Disk Space**: 20GB+ recommended |
| 44 | |
| 45 | Verify installation: |
| 46 | |
| 47 | ```bash |
| 48 | docker --version |
| 49 | docker compose version |
| 50 | ``` |
| 51 | |
| 52 | --- |
| 53 | |
| 54 | ## 🚀 Get Running in 3 Minutes |
| 55 | |
| 56 | Just 3 steps to run the complete AiToEarn on your machine. |
| 57 | |
| 58 | ### Step 1: Clone and Start |
| 59 | |
| 60 | ```bash |
| 61 | git clone https://github.com/yikart/AiToEarn.git |
| 62 | cd AiToEarn |
| 63 | docker compose up -d |
| 64 | ``` |
| 65 | |
| 66 | First startup pulls images — may take a few minutes. Run `docker compose ps` to confirm all services are `healthy` or `running`. |
| 67 | |
| 68 | ### Step 2: Open the UI |
| 69 | |
| 70 | Visit: **[http://localhost:8080](http://localhost:8080)** |
| 71 | |
| 72 | > First startup auto-creates an admin account and logs you in automatically. |
| 73 | |
| 74 | ### Step 3: Configure Relay (Strongly Recommended) |
| 75 | |
| 76 | > **Why configure Relay?** |
| 77 | > |
| 78 | > AiToEarn needs to log into your social media accounts (TikTok, Instagram, YouTube, etc.) to publish content. These platforms require OAuth developer credentials for authorization. |
| 79 | > |
| 80 | > - **Without Relay**: You'd need to register as a developer on each platform and obtain client_id/secret — extremely tedious. |
| 81 | > - **With Relay**: Use the official aitoearn.ai credentials to authorize all platforms with **just one API Key**. |
| 82 | |
| 83 | **How to configure**: |
| 84 | |
| 85 | 1. Sign up at [aitoearn.ai](https://aitoearn.ai) (international) or [aitoearn.cn](https://aitoearn.cn) (China), go to **Settings → API Key**, and create an API Key |
| 86 | 2. Open the deployed UI in your browser and go to **Configuration** |
| 87 | 3. Select **Server → Relay** and configure Relay for publishing platform authorization |
| 88 | 4. To use AI models provided by the platform, select **AI → Relay** and configure AI Relay |
| 89 | 5. For OpenAI, Gemini, Anthropic, and other model providers, you can also fill in the platform-provided API key and API URL under **AI → Model providers** |
| 90 | 6. After saving, click **Save and restart** so the corresponding service reloads the configuration |
| 91 | |
| 92 | China keys must use `https://aitoearn.cn/api`, and international keys must use `https://aitoearn.ai/api`; mismatched environments return 401. |
| 93 | |
| 94 | **You're all set!** 🎉 |
| 95 | |
| 96 | ## Operations Reference |
| 97 | |
| 98 | ### Auto-Login |
| 99 | |
| 100 | Enabled by default. On first startup, `aitoearn-init` generates an admin token saved to a shared volume. `aitoearn-web` reads it automatically. |
| 101 | |
| 102 | ### Image Pull Policy |
| 103 | |
| 104 | All app images use `pull_policy: always` to pull the latest on every `docker compose up`. |
| 105 | |
| 106 | ### Internal Service Communication |
| 107 | |
| 108 | These settings handle inter-service communication via Docker networking. Usually no changes needed: |
| 109 | |
| 110 | | Setting | Service | Default | |
| 111 | |----------|---------|---------| |
| 112 | | `serverClient.baseUrl` | aitoearn-ai | `http://aitoearn-server:3002` | |
| 113 | | `aiClient.baseUrl` | aitoearn-server | `http://aitoearn-ai:3010` | |
| 114 | |
| 115 | ### Config Files |
| 116 | |
| 117 | Mounted as writable volumes and editable from the Configuration UI. Restart the corresponding service after changes: |
| 118 | |
| 119 | | File | Mounted to | Description | |
| 120 | |------|------------|-------------| |
| 121 | | `project/aitoearn-backend/apps/aitoearn-ai/config/config.yaml` | aitoearn-ai:/app/config.yaml | AI service config | |
| 122 | | `project/aitoearn-backend/apps/aitoearn-server/config/config.yaml` | aitoearn-server:/app/config.yaml | Backend config | |
| 123 | |
| 124 | --- |
| 125 | |
| 126 | ## Configuration Quick Reference |
| 127 | |
| 128 | `aitoearn-ai` and `aitoearn-server` no longer use `docker-compose.yml` `environment` entries for runtime settings. They read the mounted `config.yaml`, which you can edit from the Configuration UI. |
| 129 | |
| 130 | ### Environment Variables Still Kept in Compose |
| 131 | |
| 132 | | Variable | Service(s) | Description | Default | |
| 133 | |----------|------------|-------------|---------| |
| 134 | | `MONGO_INITDB_ROOT_PASSWORD` | mongodb | MongoDB root password | `password` | |
| 135 | | `RUSTFS_ACCESS_KEY` / `RUSTFS_SECRET_KEY` | rustfs | RustFS credentials | `rustfsadmin` | |
| 136 | | `MONGO_URI` / `JWT_SECRET` / `DB_NAME` / `AUTO_LOGIN_TOKEN_PATH` | aitoearn-init | First-start admin initialization and auto-login token | Built-in defaults | |
| 137 | | `NODE_ENV` / `NEXT_TELEMETRY_DISABLED` | aitoearn-web | Web runtime mode and Next.js telemetry setting | `production` / `1` | |
| 138 |