# Easypanel Deploy - Usage Guide

## 🚀 Quick Start

```
/use easypanel-deploy
```

## 📋 What It Does

Deploy and manage Easypanel services via API:

1. **Deploy new service** - From Git repository
2. **Redeploy existing** - Trigger new build
3. **Check status** - View deployment status
4. **View logs** - Recent deployment logs

## 🔧 Prerequisites

### Setup Credentials

Create `~/.easypanel/credentials`:

```bash
EASYPANEL_URL=http://110.164.146.47:3000
EASYPANEL_API_TOKEN=your-token-here
EASYPANEL_DEFAULT_PROJECT=default
```

### Get API Token

1. Login to Easypanel: `http://110.164.146.47:3000`
2. Settings → API
3. Generate new token
4. Copy to credentials file

### API Documentation

Full API docs: `http://110.164.146.47:3000/api`

API uses tRPC format:
- GET: `/api/trpc/<endpoint>?input=<encoded-json>`
- POST: `/api/trpc/<endpoint>` with `{"input":{"json":{...}}}`

## 📝 Commands

### Deploy New Service

```
/use easypanel-deploy deploy
→ Project name
→ Service name
→ Git URL
→ Branch
→ Port
```

**Uses API:**
1. `projects.createProject`
2. `services.app.createService`
3. `services.app.updateSourceGit`
4. `services.app.deployService`

### Redeploy Existing

```
/use easypanel-deploy redeploy
→ Project name
→ Service name
```

**Uses API:**
1. `projects.listProjectsAndServices`
2. `services.app.deployService`

### Check Status

```
/use easypanel-deploy status
→ Project name
→ Service name
```

**Uses API:**
1. `projects.listProjectsAndServices`
2. `services.app.inspectService`
3. `monitor.getServiceStats`

### View Logs

```
/use easypanel-deploy logs
→ Project name
→ Service name
→ Lines (optional)
```

**Uses API:**
1. `services.common.getLogs`

## 🔄 Auto-Deploy

After initial setup:
- Push to Git
- Easypanel auto-deploys
- Use skill to check status/logs

## ⚠️ Troubleshooting

| Issue | Solution |
|-------|----------|
| 401 Unauthorized | Check API token |
| 404 Not Found | Verify project/service name |
| Build Failed | View logs with `logs` command |
| Can't connect | Check Easypanel URL |

## 🛠️ Tech Stack

- **Easypanel** - Deployment platform
- **Docker** - Containerization
- **Git** - Gitea/GitHub/GitLab

## 📊 Example API Calls

### List Projects
```bash
curl "http://110.164.146.47:3000/api/trpc/projects.listProjects" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### Deploy Service
```bash
curl -X POST "http://110.164.146.47:3000/api/trpc/services.app.deployService" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"input":{"json":{"projectName":"my-project","serviceName":"my-service"}}}'
```

### Get Logs
```bash
curl "http://110.164.146.47:3000/api/trpc/services.common.getLogs?input=%7B%22json%22%3A%7B%22projectName%22%3A%22my-project%22%2C%22serviceName%22%3A%22my-service%22%2C%22lines%22%3A50%7D%7D" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

## 🎯 Output

After deployment:
- ✅ Service URL
- ✅ Deployment status
- ✅ Health check status
- ✅ Build summary
