# Coolify Tool Suite

Manage Coolify container deployment platform (projects, services, deployments, environment variables).

## Prerequisites

- `jq` and `curl` installed
- Coolify credentials in `~/.config/mosaic/credentials.json` (or `$MOSAIC_CREDENTIALS_FILE`)
- Required fields: `coolify.url`, `coolify.app_token`

## Scripts

| Script              | Purpose                               |
| ------------------- | ------------------------------------- |
| `team-list.sh`      | List teams                            |
| `project-list.sh`   | List projects                         |
| `service-list.sh`   | List all services                     |
| `service-status.sh` | Get service details and status        |
| `deploy.sh`         | Trigger service deployment            |
| `env-set.sh`        | Set environment variable on a service |

## Common Options

- `-f json` — JSON output (default: table)
- `-u uuid` — Service UUID (for service-specific operations)
- `-h` — Show help

## API Reference

- Base URL: `http://10.1.1.44:8000`
- API prefix: `/api/v1/`
- Auth: Bearer token in `Authorization` header
- Rate limit: 200 requests per interval

## Known Limitations

- **FQDN updates on compose sub-apps not supported via API.** Workaround: update directly in Coolify's PostgreSQL DB (`coolify-db` container, `service_applications` table).
- **Compose must be base64-encoded** in `docker_compose_raw` field when creating services via API.
- **Don't send `type` with `docker_compose_raw`** — API rejects payloads with both fields.

## Coolify Magic Variables

Coolify reads special env vars from compose files:

- `SERVICE_FQDN_{NAME}_{PORT}` — assigns a domain to a compose service
- `SERVICE_URL_{NAME}_{PORT}` — internal URL reference
- Must use list-style env syntax (`- SERVICE_FQDN_API_3001`), NOT dict-style.

## Examples

```bash
# List all projects
~/.config/mosaic/tools/coolify/project-list.sh

# List services as JSON
~/.config/mosaic/tools/coolify/service-list.sh -f json

# Check service status
~/.config/mosaic/tools/coolify/service-status.sh -u <uuid>

# Set an env var
~/.config/mosaic/tools/coolify/env-set.sh -u <uuid> -k DATABASE_URL -v "postgres://..."

# Deploy a service
~/.config/mosaic/tools/coolify/deploy.sh -u <uuid>
```
