refactor: Move Astro project to root directory
- Move all Astro files from dealplustech-astro/ to root - Archive Next.js code in _nextjs-backup/ - Update .gitignore for Astro project - Simplify project structure This completes the migration from Next.js to Astro. The Astro project is now at the root level.
This commit is contained in:
302
DEPLOY_EASYPANEL.md
Normal file
302
DEPLOY_EASYPANEL.md
Normal file
@@ -0,0 +1,302 @@
|
||||
# 🚀 Easypanel API Deployment Guide
|
||||
|
||||
## Overview
|
||||
|
||||
This guide shows how to deploy the Deal Plus Tech Astro site to Easypanel using their API.
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. **Easypanel Access**
|
||||
- URL: `http://110.164.146.46:3000`
|
||||
- Admin credentials
|
||||
|
||||
2. **API Token**
|
||||
- Login to Easypanel
|
||||
- Go to Settings → API
|
||||
- Generate new API token
|
||||
|
||||
3. **Docker Image**
|
||||
- Already built locally: `dealplustech-astro:latest`
|
||||
- Size: 564MB
|
||||
|
||||
---
|
||||
|
||||
## Method 1: Manual Deployment (Recommended)
|
||||
|
||||
### Step 1: Login to Easypanel
|
||||
|
||||
```
|
||||
URL: http://110.164.146.46:3000
|
||||
```
|
||||
|
||||
### Step 2: Create Project
|
||||
|
||||
1. Click **"New Project"**
|
||||
2. Name: `dealplustech`
|
||||
3. Description: "Deal Plus Tech Websites"
|
||||
4. Click **"Create"**
|
||||
|
||||
### Step 3: Deploy Docker Image
|
||||
|
||||
1. Select project: `dealplustech`
|
||||
2. Click **"New Service"**
|
||||
3. Choose: **"Docker Image"**
|
||||
4. Configure:
|
||||
- **Name:** `dealplustech-astro`
|
||||
- **Image:** `dealplustech-astro:latest`
|
||||
- **Port:** `4321`
|
||||
5. Click **"Deploy"**
|
||||
|
||||
### Step 4: Verify Deployment
|
||||
|
||||
1. Wait for build to complete (~2-3 minutes)
|
||||
2. Click on service to view logs
|
||||
3. Look for: "Astro preview ready"
|
||||
4. Access URL provided by Easypanel
|
||||
|
||||
---
|
||||
|
||||
## Method 2: Automated Deployment (API)
|
||||
|
||||
### Step 1: Get API Token
|
||||
|
||||
```bash
|
||||
# Login to Easypanel and get token from Settings → API
|
||||
export EASYPANEL_API_TOKEN="your-api-token-here"
|
||||
```
|
||||
|
||||
### Step 2: Run Deployment Script
|
||||
|
||||
```bash
|
||||
cd dealplustech-astro
|
||||
|
||||
# Option A: With token as argument
|
||||
./deploy-easypanel.sh your-api-token
|
||||
|
||||
# Option B: With environment variable
|
||||
export EASYPANEL_API_TOKEN="your-api-token"
|
||||
./deploy-easypanel.sh
|
||||
```
|
||||
|
||||
### Step 3: Monitor Deployment
|
||||
|
||||
```bash
|
||||
# View service status
|
||||
curl -s "http://110.164.146.46:3000/api/trpc/services.app.inspectService" \
|
||||
-H "Authorization: Bearer $EASYPANEL_API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"input":{"json":{"projectName":"dealplustech","serviceName":"dealplustech-astro"}}}' \
|
||||
--insecure | python3 -m json.tool
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Method 3: Direct Docker Deployment
|
||||
|
||||
If you have direct Docker access to the Easypanel server:
|
||||
|
||||
```bash
|
||||
# SSH to Easypanel server
|
||||
ssh user@110.164.146.46
|
||||
|
||||
# Run container directly
|
||||
docker run -d \
|
||||
-p 4321:4321 \
|
||||
--name dealplustech-astro \
|
||||
--restart unless-stopped \
|
||||
-e NODE_ENV=production \
|
||||
-e PORT=4321 \
|
||||
-e HOST=0.0.0.0 \
|
||||
dealplustech-astro:latest
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### List Projects
|
||||
|
||||
```bash
|
||||
curl -X GET "http://110.164.146.46:3000/api/trpc/projects.listProjects" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
--insecure
|
||||
```
|
||||
|
||||
### Create Service
|
||||
|
||||
```bash
|
||||
curl -X POST "http://110.164.146.46:3000/api/trpc/services.app.create" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{
|
||||
"projectName": "dealplustech",
|
||||
"name": "dealplustech-astro",
|
||||
"type": "docker",
|
||||
"docker": {
|
||||
"image": "dealplustech-astro:latest",
|
||||
"port": 4321
|
||||
},
|
||||
"env": {
|
||||
"NODE_ENV": "production",
|
||||
"PORT": "4321"
|
||||
}
|
||||
}' \
|
||||
--insecure
|
||||
```
|
||||
|
||||
### Inspect Service
|
||||
|
||||
```bash
|
||||
curl -X GET "http://110.164.146.46:3000/api/trpc/services.app.inspectService" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"input":{"json":{"projectName":"dealplustech","serviceName":"dealplustech-astro"}}}' \
|
||||
--insecure
|
||||
```
|
||||
|
||||
### Get Service Logs
|
||||
|
||||
```bash
|
||||
curl -X GET "http://110.164.146.46:3000/api/trpc/services.common.getLogs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"input":{"json":{"projectName":"dealplustech","serviceName":"dealplustech-astro","lines":50}}}' \
|
||||
--insecure
|
||||
```
|
||||
|
||||
### Deploy/Redeploy Service
|
||||
|
||||
```bash
|
||||
curl -X POST "http://110.164.146.46:3000/api/trpc/services.app.deploy" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"input":{"json":{"projectName":"dealplustech","serviceName":"dealplustech-astro"}}}' \
|
||||
--insecure
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Value | Required |
|
||||
|----------|-------|----------|
|
||||
| `NODE_ENV` | `production` | ✅ Yes |
|
||||
| `PORT` | `4321` | ✅ Yes |
|
||||
| `HOST` | `0.0.0.0` | ✅ Yes |
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### API Returns 401 Unauthorized
|
||||
|
||||
**Problem:** Invalid or missing API token
|
||||
|
||||
**Solution:**
|
||||
```bash
|
||||
# Verify token is set
|
||||
echo $EASYPANEL_API_TOKEN
|
||||
|
||||
# Regenerate token in Easypanel dashboard
|
||||
```
|
||||
|
||||
### Service Won't Start
|
||||
|
||||
**Problem:** Container crashes on startup
|
||||
|
||||
**Solution:**
|
||||
```bash
|
||||
# Check logs
|
||||
docker logs dealplustech-astro
|
||||
|
||||
# Common issues:
|
||||
# - Port already in use
|
||||
# - Missing environment variables
|
||||
# - Image build failed
|
||||
```
|
||||
|
||||
### Build Fails
|
||||
|
||||
**Problem:** Docker build errors
|
||||
|
||||
**Solution:**
|
||||
```bash
|
||||
# Rebuild with verbose output
|
||||
cd dealplustech-astro
|
||||
docker build --no-cache -t dealplustech-astro:latest .
|
||||
|
||||
# Check for errors in output
|
||||
```
|
||||
|
||||
### Can't Access Easypanel
|
||||
|
||||
**Problem:** Connection timeout
|
||||
|
||||
**Solution:**
|
||||
```bash
|
||||
# Test connection
|
||||
curl -I http://110.164.146.46:3000
|
||||
|
||||
# Check if Easypanel is running
|
||||
# Contact server administrator if needed
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Post-Deployment
|
||||
|
||||
### 1. Verify Service
|
||||
|
||||
```bash
|
||||
curl http://your-easypanel-url:4321/
|
||||
```
|
||||
|
||||
Should return HTML with Thai content
|
||||
|
||||
### 2. Check Health
|
||||
|
||||
```bash
|
||||
curl -I http://your-easypanel-url:4321/
|
||||
```
|
||||
|
||||
Should return `HTTP/1.1 200 OK`
|
||||
|
||||
### 3. Setup Domain (Optional)
|
||||
|
||||
1. Go to Easypanel → Service Settings → Domains
|
||||
2. Add domain: `dealplustech.co.th`
|
||||
3. Update DNS records
|
||||
4. Enable SSL
|
||||
|
||||
### 4. Enable Auto-Deploy
|
||||
|
||||
For Git-based auto-deploy:
|
||||
1. Go to Service Settings → Git
|
||||
2. Connect repository
|
||||
3. Enable auto-deploy on push
|
||||
|
||||
---
|
||||
|
||||
## Resources
|
||||
|
||||
- **Easypanel Dashboard:** http://110.164.146.46:3000
|
||||
- **API Documentation:** http://110.164.146.46:3000/api
|
||||
- **Swagger UI:** http://110.164.146.46:3000/api (Swagger UI)
|
||||
- **Easypanel Docs:** https://docs.easypanel.io
|
||||
|
||||
---
|
||||
|
||||
## Support
|
||||
|
||||
For issues:
|
||||
1. Check service logs in Easypanel
|
||||
2. Review deployment script output
|
||||
3. Contact Easypanel support
|
||||
4. Check project documentation
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** 2026-03-02
|
||||
**Status:** ✅ Ready for Deployment
|
||||
Reference in New Issue
Block a user