# 🚀 Gitea Repository Deployment - BEST METHOD!

## ✅ Why This is Better

| Method | Docker Registry | Gitea Repo |
|--------|----------------|------------|
| Build locally | ✅ Required | ❌ Not needed |
| Push to registry | ✅ Required | ❌ Not needed |
| Easypanel builds | ❌ No | ✅ Yes! |
| Auto-deploy on push | ❌ No | ✅ Yes! |
| Version control | ❌ No | ✅ Yes! |
| Rollbacks | ❌ Hard | ✅ Easy |

---

## 🎯 How It Works

```
┌─────────────┐     ┌──────────────┐     ┌─────────────┐
│   You Git   │     │   Easypanel  │     │   Deployed  │
│    Push     │────▶│   Clones &   │────▶│   Service   │
│  to Gitea   │     │   Builds     │     │   Running   │
└─────────────┘     └──────────────┘     └─────────────┘
```

**Easypanel will:**
1. Clone your Gitea repository
2. Run `npm install`
3. Run `npm run build`
4. Deploy the `dist/` folder
5. Serve on port 4321

---

## 📋 Setup Steps

### Step 1: Run Deploy Script

```bash
cd dealplustech-astro
./skills/easypanel-deploy/deploy.sh deploy
```

**It will show:**
```
Gitea URL: http://110.164.146.46:3001
Repository: dealplustech/dealplustech-astro
Branch: main
Build Command: npm run build
Publish Directory: dist
Port: 4321
```

### Step 2: Create Service in Easypanel

```
1. Open: http://110.164.146.46:3000

2. Select Project: customerwebsite

3. Click: New Service → Git Repository

4. Configure:
   ┌─────────────────────────────────────┐
   │ Repository URL:                     │
   │ http://110.164.146.46:3001/        │
   │ dealplustech/dealplustech-astro    │
   └─────────────────────────────────────┘
   
   ┌─────────────────────────────────────┐
   │ Branch: main                        │
   └─────────────────────────────────────┘
   
   ┌─────────────────────────────────────┐
   │ Build Command: npm run build        │
   └─────────────────────────────────────┘
   
   ┌─────────────────────────────────────┐
   │ Publish Directory: dist             │
   └─────────────────────────────────────┘
   
   ┌─────────────────────────────────────┐
   │ Port: 4321                          │
   └─────────────────────────────────────┘

5. Click: Deploy
```

### Step 3: Wait for Build

Easypanel will:
- ✅ Clone from Gitea (~10 seconds)
- ✅ Run `npm install` (~30 seconds)
- ✅ Run `npm run build` (~20 seconds)
- ✅ Deploy `dist/` (~5 seconds)

**Total: ~1 minute**

### Step 4: Register Service ID

After deployment completes:

```bash
# Copy Service ID from Easypanel dashboard
./skills/easypanel-deploy/deploy.sh register svc_xxx...
```

---

## 🔄 Automatic Updates

### Enable Auto-Deploy

**In Easypanel:**
1. Go to service settings
2. Click: Git → Auto Deploy
3. Enable: Auto Deploy on Push

**Then:**
```bash
# Make changes
git add .
git commit -m "Update something"
git push

# Easypanel automatically rebuilds! 🎉
```

### Manual Redeploy

```bash
./skills/easypanel-deploy/deploy.sh redeploy
```

---

## ✅ Benefits

### 1. No Docker Registry
- ❌ No `docker build`
- ❌ No `docker push`
- ❌ No registry credentials

### 2. Automatic Deployments
- ✅ Push to Gitea
- ✅ Easypanel rebuilds
- ✅ Zero manual steps

### 3. Version Control
- ✅ Every commit = potential deployment
- ✅ Easy rollbacks
- ✅ Change history

### 4. Build Caching
- ✅ `node_modules` cached
- ✅ Faster builds
- ✅ Efficient

---

## 🔧 Configuration

### Gitea Repository

```bash
URL: http://110.164.146.46:3001
Owner: dealplustech
Repo: dealplustech-astro
Branch: main
```

### Build Settings

```bash
Build Command: npm run build
Publish Directory: dist/
Node Version: 20 (from .nvmrc or package.json)
```

### Environment Variables

Add in Easypanel service settings:

```bash
NODE_ENV=production
NEXT_PUBLIC_SITE_URL=https://your-domain.com
```

---

## 📁 Required Files

Your repository should have:

```
dealplustech-astro/
├── package.json          ✅ Required (defines build)
├── Dockerfile            ⚠️ Optional (for Docker mode)
├── astro.config.mjs      ✅ Required
├── src/                  ✅ Required
└── .gitignore            ✅ Required
```

---

## 🎯 Next Action

**Deploy now:**

```bash
# 1. Run deployment script
./skills/easypanel-deploy/deploy.sh deploy

# 2. Follow instructions to create service in Easypanel

# 3. After deployment:
./skills/easypanel-deploy/deploy.sh register SERVICE_ID

# 4. Enable auto-deploy in Easypanel

# 5. Future updates: just git push!
```

---

**This is THE BEST way to deploy!** 🎉

- No Docker needed
- No registry needed
- Automatic deployments
- Full version control
