|
| 1 | +# CoexistAI — Docker Quickstart |
| 2 | + |
| 3 | +### Short, step-by-step instructions for two ways to start CoexistAI. Pick either Method A (helper script) or Method B (direct Docker Compose). |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | +- Docker Engine installed. |
| 7 | + |
| 8 | +## Before you start (one-time) |
| 9 | +1. Open a terminal and change into the repository folder: |
| 10 | + |
| 11 | +```bash |
| 12 | +cd /path/to/CoexistAI |
| 13 | +``` |
| 14 | + |
| 15 | +2. Edit the .env file for keys and admin token (which will be used while editing model params): |
| 16 | + |
| 17 | + |
| 18 | +## Method A — Helper script (recommended for beginners) |
| 19 | +This script automates the compose start and waits until the app reports ready. |
| 20 | + |
| 21 | +1. Run the helper (from repo root): |
| 22 | + |
| 23 | +```bash |
| 24 | +./quick_setup_docker.sh |
| 25 | +``` |
| 26 | +or |
| 27 | + |
| 28 | +```bash # default timeout 300s |
| 29 | +./quick_setup_docker.sh 600 # pass timeout in seconds (example: 600s = 10min) |
| 30 | +``` |
| 31 | + |
| 32 | + For subsequent starts, run the script again (it detects the existing image and skips building/installing). |
| 33 | + |
| 34 | +2. What the script does (so you know what to expect): |
| 35 | +- Checks if the Docker image 'coexistai-app' already exists; if yes, runs `docker compose up -d` (no build); if not, runs `docker compose up -d --build` to start containers detached. |
| 36 | +- Polls `http://localhost:8000/status` every few seconds and prints a spinner. |
| 37 | +- Exits with code 0 when the app reports `{"status":"ready"}`. |
| 38 | +- Exits non-zero if the app reports `error` or the timeout is reached. |
| 39 | + |
| 40 | +3. After the script finishes successfully, open: |
| 41 | + |
| 42 | +- http://localhost:8000/admin |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +- If using local models ignore api_keys fields |
| 47 | + |
| 48 | +- By default ADMIN_TOKEN=123456, you can change it via .env |
| 49 | + |
| 50 | + This opens the Admin UI, where you can edit model configurations, API keys, and reload settings without rebuilding the container. |
| 51 | + |
| 52 | +When to use Method A: you're new to Docker or want a simple way to wait until the app is ready. |
| 53 | + |
| 54 | + |
| 55 | +## Method B — Direct Docker Compose (fast, manual) |
| 56 | +1. Start the stack: |
| 57 | + |
| 58 | + - **First time** (builds the image): |
| 59 | + ```bash |
| 60 | + docker compose up -d --build |
| 61 | + ``` |
| 62 | + |
| 63 | + - **Subsequent times** (uses existing image): |
| 64 | + ```bash |
| 65 | + docker compose up -d |
| 66 | + ``` |
| 67 | + |
| 68 | + To stop: `docker compose down` |
| 69 | + |
| 70 | + To restart: `docker compose restart` |
| 71 | + |
| 72 | +2. Wait for ready signal in terminal where you ran docker compose, then open the admin UI: |
| 73 | + |
| 74 | +- http://localhost:8000/admin |
| 75 | + |
| 76 | +3. Verify status from the host: |
| 77 | + |
| 78 | +```bash |
| 79 | +curl http://localhost:8000/status |
| 80 | +# expected JSON: {"status":"starting"} or {"status":"ready"} |
| 81 | +``` |
| 82 | + |
| 83 | +4. Edit configuration: |
| 84 | +- Use the Admin UI `/admin` and click "Save & Reload" to apply changes without rebuilding. |
| 85 | +- Or from the host (curl): |
| 86 | + |
| 87 | +```bash |
| 88 | +curl -X POST -H "X-Admin-Token: $ADMIN_TOKEN" http://localhost:8000/admin/reload-config |
| 89 | +``` |
| 90 | + |
| 91 | +When to use Method A: you prefer to run compose directly and watch logs yourself. |
| 92 | + |
| 93 | +Secrets (recommended pattern) |
| 94 | +- Do not store API keys in the repo. Use `.env` or file-backed secrets. |
| 95 | +- Recommended: create `CoexistAI/config/keys/` on the host, place key files there, and mount that folder into the container. Reference them in `config/model_config.json` with `llm_api_key_file` / `embed_api_key_file`. |
| 96 | + |
| 97 | +Quick troubleshooting |
| 98 | +- App unreachable? Check app logs: |
| 99 | + |
| 100 | +```bash |
| 101 | +docker compose logs app --tail=200 |
| 102 | +``` |
| 103 | + |
| 104 | +- App timed out in `quick_setup_docker.sh` or reports `error`? Inspect logs and increase timeout: |
| 105 | + |
| 106 | +```bash |
| 107 | +docker compose logs app --tail=400 |
| 108 | +./quick_setup_docker.sh 600 |
| 109 | +``` |
| 110 | + |
| 111 | +- Long model downloads or HF errors: allow more time on first start or mount `artifacts/` (HF cache) into the container to avoid repeated downloads. |
| 112 | + |
| 113 | +Helpful commands |
| 114 | + |
| 115 | +```bash |
| 116 | +# Check status |
| 117 | +curl http://localhost:8000/status |
| 118 | +
|
| 119 | +# Ask app to reload config (from host) |
| 120 | +curl -X POST -H "X-Admin-Token: $ADMIN_TOKEN" http://localhost:8000/admin/reload-config |
| 121 | +
|
| 122 | +# Follow logs interactively |
| 123 | +docker compose logs -f app --tail=200 |
| 124 | +``` |
| 125 | + |
0 commit comments