# AIGO - Docker Deployment ## Project Structure ``` aigo-docker/ ├── Dockerfile # 3-stage: composer → npm build → php:8.2-apache ├── docker-compose.yml # 4 services: app, reverb, queue, db ├── docker-entrypoint.sh # Waits for DB, runs migrate/cache/link ├── .env.example # All required env vars ├── .dockerignore ├── docker/apache/ │ └── 000-default.conf # DocumentRoot = /var/www/aigo/public ├── aigo/ # Laravel source (git-tracked) │ ├── app/ │ ├── config/ │ ├── routes/ │ ├── resources/ # Blade views, JS (echo.js), CSS │ ├── public/ # Static assets, build output │ ├── composer.json │ ├── package.json │ └── ... └── humicpro_aigo.sql # Database dump (auto-imported by MySQL) ``` ## Build Stages | Stage | Image | Purpose | |-------|-------|---------| | `composer` | `composer:2.7` | `composer install --no-dev` | | `npm` | `node:20-slim` | `npm ci && npm run build` (compiles VITE_* vars into JS) | | `runtime` | `php:8.2-apache` | Apache + PHP with `mod_rewrite`, `pdo_mysql`, `redis` | ## Deploy to Coolify 1. Push this repo to GitHub/GitLab 2. In Coolify, create a new project → select your repo 3. Coolify auto-detects `docker-compose.yml` 4. Set these **environment variables** in Coolify's UI: ### Required | Variable | Description | How to get it | |----------|-------------|---------------| | `APP_URL` | Your domain | `https://your-domain.com` | | `APP_KEY` | Laravel encryption key | Run `php artisan key:generate --show` locally | | `DB_PASSWORD` | MySQL user password | Choose a secure password | | `DB_ROOT_PASSWORD` | MySQL root password | Choose a secure password | ### WebSocket (Reverb) | Variable | Description | Example | |----------|-------------|---------| | `VITE_REVERB_HOST` | Your Coolify domain | `your-domain.com` | | `VITE_REVERB_PORT` | WebSocket port | `8080` | | `VITE_REVERB_SCHEME` | `https` if Traefik handles TLS | `https` | These VITE_* vars are build args — they get compiled into the JS bundle. To change them, update the env var in Coolify and rebuild. ### Optional | Variable | Default | |----------|---------| | `STRAVA_CLIENT_ID` | `124405` | | `STRAVA_CLIENT_SECRET` | (leave blank if not used) | | `REVERB_APP_ID` | `103594` | | `REVERB_APP_KEY` | `zlno4t94kysjzmtwlmux` | | `REVERB_APP_SECRET` | `7zpl1vq4qvvotvrodq2u` | 5. In the **reverb** service settings, expose port **8080** via Traefik 6. Deploy — MySQL auto-imports `humicpro_aigo.sql` on first startup ## Architecture ``` Browser ──HTTPS──> Coolify/Traefik ──> app container (port 80 / Apache) Browser ──WSS──> Coolify/Traefik ──> reverb container (port 8080 / Reverb WebSocket) ``` ## Services | Service | Image | Purpose | |---------|-------|---------| | `app` | Built from Dockerfile | Apache + PHP-FPM, serves the Laravel app | | `reverb` | Same image | Runs `php artisan reverb:start` for real-time WebSocket | | `queue` | Same image | Runs `php artisan queue:work` for background jobs | | `db` | `mysql:8.0` | MySQL database with auto-import of SQL dump | ## Maintenance - **Storage**: Persistent volume `aigo-storage` at `/var/www/aigo/storage` - **Database**: Persistent volume `dbdata` at `/var/lib/mysql` - **Logs**: Available via `docker compose logs -f [service]` - **To change domain**: Update `APP_URL` + `VITE_REVERB_HOST` in Coolify, rebuild