---
name: coolify-deployer
description: Deploys applications to Coolify PaaS with automated configuration. Use when deploying or managing applications on Coolify.
argument-hint: "[app-path] [--env=production]"
allowed-tools: [Read, Write, Bash, Task]
disable-model-invocation: true
---

# Coolify Deployer Skill

Deploy applications to Coolify self-hosted PaaS with automated configuration, environment management, and deployment automation.

## Capabilities

- Application deployment to Coolify
- Environment variable management
- Database provisioning
- SSL certificate management
- Domain configuration
- Deployment status monitoring
- Rollback support

## Prerequisites

Configure Coolify credentials:

```bash
/myai-configure coolify
```

Or set environment variables:
```
COOLIFY_API_KEY=your_api_key
COOLIFY_URL=https://coolify.yourdomain.com
```

## Deployment Types

| Type | Description |
|------|-------------|
| **Docker** | Deploy from Dockerfile |
| **Docker Compose** | Multi-container apps |
| **Git** | Deploy from repository |
| **Static** | Static site deployment |
| **Database** | PostgreSQL, MySQL, MongoDB, Redis |

## Process

1. **Configuration**
   - Detect application type
   - Parse existing configuration
   - Generate Coolify-compatible config

2. **Environment Setup**
   - Create/select project
   - Configure environment variables
   - Set up domains and SSL

3. **Deployment**
   - Push to Coolify
   - Monitor build process
   - Verify deployment

4. **Verification**
   - Health check
   - DNS verification
   - SSL validation

## Parameters

| Parameter | Description | Default |
|-----------|-------------|---------|
| `app-path` | Path to application | ./ |
| `--env` | Environment (dev, staging, prod) | production |
| `--project` | Coolify project name | auto |
| `--domain` | Custom domain | none |
| `--ssl` | Enable SSL | true |
| `--db` | Provision database type | none |

## Example Usage

```bash
# Deploy current directory
/myaidev-method:coolify-deploy

# Deploy to staging
/myaidev-method:coolify-deploy --env=staging

# Deploy with custom domain
/myaidev-method:coolify-deploy --domain=app.example.com

# Deploy with database
/myaidev-method:coolify-deploy --db=postgresql

# Deploy specific path
/myaidev-method:coolify-deploy ./apps/api --env=production
```

## Configuration File

Create `coolify.json` in project root:

```json
{
  "name": "my-app",
  "type": "docker",
  "domain": "app.example.com",
  "ssl": true,
  "env": {
    "NODE_ENV": "production",
    "DATABASE_URL": "${DB_URL}"
  },
  "healthCheck": {
    "path": "/health",
    "interval": 30
  },
  "resources": {
    "memory": "512Mi",
    "cpu": "0.5"
  }
}
```

## Environment Variables

Variables are managed per environment:

```bash
# Set for production
coolify env set --env=production API_KEY=xxx

# Copy from local .env
coolify env import --env=staging .env.staging
```

## Database Provisioning

Supported databases with auto-configuration:

| Database | Connection String |
|----------|-------------------|
| PostgreSQL | `postgresql://...` |
| MySQL | `mysql://...` |
| MongoDB | `mongodb://...` |
| Redis | `redis://...` |

## Deployment Output

```markdown
# Deployment Summary

## Application
- **Name**: my-app
- **Environment**: production
- **Status**: ✅ Deployed

## Endpoints
- **URL**: https://app.example.com
- **Health**: https://app.example.com/health

## Resources
- **Memory**: 512Mi
- **CPU**: 0.5 cores
- **Replicas**: 2

## Build Info
- **Duration**: 2m 34s
- **Image**: my-app:abc123
- **Size**: 234MB

## Next Steps
1. Verify application at URL
2. Check logs: `coolify logs my-app`
3. Set up monitoring
```

## Integration

- Works with git workflows for CI/CD
- Supports environment promotion (dev → staging → prod)
- Integrates with monitoring and logging

## Rollback

```bash
# Rollback to previous version
/myaidev-method:coolify-deploy --rollback

# Rollback to specific version
/myaidev-method:coolify-deploy --rollback=v1.2.3
```

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Build failed | Check Dockerfile and logs |
| Domain not resolving | Verify DNS configuration |
| SSL error | Check domain ownership |
| Health check failing | Verify health endpoint |
| Out of memory | Increase resource limits |
