690319:2309 Update Backend & Frontend dep. #03
Build and Deploy / deploy (push) Has been cancelled
Build and Deploy / deploy (push) Has been cancelled
This commit is contained in:
@@ -17,8 +17,8 @@ jobs:
|
|||||||
username: ${{ secrets.USERNAME }}
|
username: ${{ secrets.USERNAME }}
|
||||||
password: ${{ secrets.PASSWORD }}
|
password: ${{ secrets.PASSWORD }}
|
||||||
port: ${{ secrets.PORT }}
|
port: ${{ secrets.PORT }}
|
||||||
timeout: 900s # 15 minutes total timeout
|
timeout: 1200s # 20 minutes total timeout (เพิ่มจาก 15 นาที)
|
||||||
command_timeout: 600s # 10 minutes per command timeout
|
command_timeout: 900s # 15 minutes per command timeout (เพิ่มจาก 10 นาที)
|
||||||
script_stop_signal: true # Stop script on error
|
script_stop_signal: true # Stop script on error
|
||||||
script: |
|
script: |
|
||||||
set -e
|
set -e
|
||||||
@@ -49,8 +49,25 @@ jobs:
|
|||||||
# Sync compose file จาก repo → app directory
|
# Sync compose file จาก repo → app directory
|
||||||
cp /share/np-dms/app/source/lcbp3/specs/04-Infrastructure-OPS/04-00-docker-compose/docker-compose-app.yml /share/np-dms/app/docker-compose-app.yml
|
cp /share/np-dms/app/source/lcbp3/specs/04-Infrastructure-OPS/04-00-docker-compose/docker-compose-app.yml /share/np-dms/app/docker-compose-app.yml
|
||||||
cd /share/np-dms/app
|
cd /share/np-dms/app
|
||||||
# ⚠️ ลบ container เดิมที่อาจสร้างจาก Container Station
|
|
||||||
|
# ⚠️ ลบ container เดิมที่อาจสร้างจาก Container Station - พยายามหลายวิธี
|
||||||
|
echo "🧹 Cleaning up existing containers..."
|
||||||
|
docker stop backend frontend 2>/dev/null || true
|
||||||
|
sleep 5
|
||||||
docker rm -f backend frontend 2>/dev/null || true
|
docker rm -f backend frontend 2>/dev/null || true
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
# ถ้ายังลบไม่ได้ ลอง force remove ด้วย container ID
|
||||||
|
for container in backend frontend; do
|
||||||
|
if docker ps -a --format "{{.Names}}" | grep -q "^${container}$"; then
|
||||||
|
echo "🔧 Force removing container: $container"
|
||||||
|
container_id=$(docker ps -a --filter "name=$container" --format "{{.ID}}")
|
||||||
|
if [ ! -z "$container_id" ]; then
|
||||||
|
docker rm -f "$container_id" 2>/dev/null || true
|
||||||
|
sleep 2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# 4a. Start Backend ก่อน
|
# 4a. Start Backend ก่อน
|
||||||
echo "🟢 Starting Backend..."
|
echo "🟢 Starting Backend..."
|
||||||
@@ -80,7 +97,11 @@ jobs:
|
|||||||
docker compose -f docker-compose-app.yml up -d frontend
|
docker compose -f docker-compose-app.yml up -d frontend
|
||||||
|
|
||||||
# 5. Cleanup
|
# 5. Cleanup
|
||||||
echo "🧹 Cleaning up unused images..."
|
echo "🧹 Cleaning up unused images and containers..."
|
||||||
docker image prune -f
|
docker image prune -f
|
||||||
|
docker system prune -f --volumes 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "📊 Final container status:"
|
||||||
|
docker ps -a
|
||||||
|
|
||||||
echo "✅ Deployment Complete!"
|
echo "✅ Deployment Complete!"
|
||||||
|
|||||||
@@ -0,0 +1,207 @@
|
|||||||
|
# Deploy Troubleshooting Guide
|
||||||
|
|
||||||
|
## 🔧 Common Deploy Issues & Solutions
|
||||||
|
|
||||||
|
### ⚠️ Container Removal Timeout
|
||||||
|
|
||||||
|
**Error**: `failed to remove container: Error response from daemon: removal of container xxx is already in progress`
|
||||||
|
|
||||||
|
**Causes**:
|
||||||
|
- Container is still running processes
|
||||||
|
- QNAP Container Station interference
|
||||||
|
- Docker daemon issues
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
#### 1. **Manual Cleanup (SSH to QNAP)**
|
||||||
|
```bash
|
||||||
|
# SSH to QNAP
|
||||||
|
ssh admin@your-qnap-ip
|
||||||
|
|
||||||
|
# Export Docker PATH
|
||||||
|
export PATH="/share/CACHEDEV1_DATA/.qpkg/container-station/bin:/opt/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
|
||||||
|
|
||||||
|
# Force stop containers
|
||||||
|
docker stop backend frontend 2>/dev/null || true
|
||||||
|
docker kill backend frontend 2>/dev/null || true
|
||||||
|
|
||||||
|
# Force remove with multiple attempts
|
||||||
|
docker rm -f backend frontend 2>/dev/null || true
|
||||||
|
sleep 3
|
||||||
|
docker rm -f $(docker ps -aq) 2>/dev/null || true
|
||||||
|
|
||||||
|
# System cleanup
|
||||||
|
docker system prune -f --volumes
|
||||||
|
docker system df
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. **Container Station GUI Fix**
|
||||||
|
1. Open QNAP Container Station
|
||||||
|
2. Stop all containers manually
|
||||||
|
3. Delete containers manually
|
||||||
|
4. Try deploy again
|
||||||
|
|
||||||
|
#### 3. **Docker Daemon Restart**
|
||||||
|
```bash
|
||||||
|
# Restart Docker service (QNAP specific)
|
||||||
|
/etc/init.d/container-station.sh restart
|
||||||
|
# Or reboot QNAP if needed
|
||||||
|
reboot
|
||||||
|
```
|
||||||
|
|
||||||
|
### ⚠️ SSH Connection Timeout
|
||||||
|
|
||||||
|
**Error**: `Run Command Timeout`
|
||||||
|
|
||||||
|
**Solutions**:
|
||||||
|
|
||||||
|
#### 1. **Increase Timeouts** (Updated in deploy.yaml)
|
||||||
|
```yaml
|
||||||
|
timeout: 1200s # 20 minutes total
|
||||||
|
command_timeout: 900s # 15 minutes per command
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. **Check Network**
|
||||||
|
```bash
|
||||||
|
# Test SSH connectivity
|
||||||
|
ssh -o ConnectTimeout=30 admin@your-qnap-ip "echo 'SSH OK'"
|
||||||
|
|
||||||
|
# Test Docker via SSH
|
||||||
|
ssh admin@your-qnap-ip "docker --version"
|
||||||
|
```
|
||||||
|
|
||||||
|
### ⚠️ Build Failures
|
||||||
|
|
||||||
|
**Frontend Build Issues**:
|
||||||
|
```bash
|
||||||
|
# Check Node.js version
|
||||||
|
node --version # Should be v18+
|
||||||
|
npm --version # Should be v9+
|
||||||
|
|
||||||
|
# Clear build cache
|
||||||
|
cd /share/np-dms/app/source/lcbp3
|
||||||
|
rm -rf frontend/.next frontend/node_modules/.cache
|
||||||
|
pnpm install
|
||||||
|
pnpm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
**Backend Build Issues**:
|
||||||
|
```bash
|
||||||
|
# Check dependencies
|
||||||
|
cd /share/np-dms/app/source/lcbp3/backend
|
||||||
|
pnpm install
|
||||||
|
pnpm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### ⚠️ Health Check Failures
|
||||||
|
|
||||||
|
**Backend not healthy**:
|
||||||
|
```bash
|
||||||
|
# Check container logs
|
||||||
|
docker logs backend
|
||||||
|
|
||||||
|
# Check container status
|
||||||
|
docker ps
|
||||||
|
docker inspect backend
|
||||||
|
|
||||||
|
# Manual health check
|
||||||
|
curl -f http://localhost:3001/health || echo "Health check failed"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🚀 Quick Deploy Commands
|
||||||
|
|
||||||
|
### Manual Deploy (SSH to QNAP)
|
||||||
|
```bash
|
||||||
|
# 1. Update code
|
||||||
|
cd /share/np-dms/app/source/lcbp3
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
|
# 2. Build images
|
||||||
|
docker build -f backend/Dockerfile -t lcbp3-backend:latest .
|
||||||
|
docker build -f frontend/Dockerfile \
|
||||||
|
--build-arg NEXT_PUBLIC_API_URL=https://backend.np-dms.work/api \
|
||||||
|
-t lcbp3-frontend:latest .
|
||||||
|
|
||||||
|
# 3. Deploy
|
||||||
|
cd /share/np-dms/app
|
||||||
|
docker compose -f docker-compose-app.yml down
|
||||||
|
docker compose -f docker-compose-app.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rollback Commands
|
||||||
|
```bash
|
||||||
|
# Stop current
|
||||||
|
cd /share/np-dms/app
|
||||||
|
docker compose -f docker-compose-app.yml down
|
||||||
|
|
||||||
|
# Use previous images (if tagged)
|
||||||
|
docker compose -f docker-compose-app.yml up -d
|
||||||
|
|
||||||
|
# Or checkout previous commit
|
||||||
|
cd /share/np-dms/app/source/lcbp3
|
||||||
|
git log --oneline -10 # Find previous commit
|
||||||
|
git checkout <previous-commit-hash>
|
||||||
|
# Then rebuild and deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📊 Monitoring Deploy Status
|
||||||
|
|
||||||
|
### Check Services
|
||||||
|
```bash
|
||||||
|
# Container status
|
||||||
|
docker ps -a
|
||||||
|
|
||||||
|
# Service URLs
|
||||||
|
curl -I https://frontend.np-dms.work
|
||||||
|
curl -I https://backend.np-dms.work/api/health
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
docker logs backend --tail 50
|
||||||
|
docker logs frontend --tail 50
|
||||||
|
```
|
||||||
|
|
||||||
|
### System Resources
|
||||||
|
```bash
|
||||||
|
# Docker system info
|
||||||
|
docker system df
|
||||||
|
docker stats
|
||||||
|
|
||||||
|
# QNAP resources
|
||||||
|
top
|
||||||
|
free -h
|
||||||
|
df -h
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🆘 Emergency Procedures
|
||||||
|
|
||||||
|
### Full Reset
|
||||||
|
```bash
|
||||||
|
# Stop everything
|
||||||
|
docker stop $(docker ps -q) 2>/dev/null || true
|
||||||
|
|
||||||
|
# Remove everything
|
||||||
|
docker rm -f $(docker ps -aq) 2>/dev/null || true
|
||||||
|
docker system prune -af --volumes
|
||||||
|
|
||||||
|
# Rebuild from scratch
|
||||||
|
cd /share/np-dms/app/source/lcbp3
|
||||||
|
git pull origin main
|
||||||
|
docker build -f backend/Dockerfile -t lcbp3-backend:latest .
|
||||||
|
docker build -f frontend/Dockerfile \
|
||||||
|
--build-arg NEXT_PUBLIC_API_URL=https://backend.np-dms.work/api \
|
||||||
|
-t lcbp3-frontend:latest .
|
||||||
|
|
||||||
|
cd /share/np-dms/app
|
||||||
|
docker compose -f docker-compose-app.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Contact Support
|
||||||
|
- Check logs: `docker logs backend`, `docker logs frontend`
|
||||||
|
- System status: `docker ps -a`, `docker system df`
|
||||||
|
- Network: `curl -I` test URLs
|
||||||
|
- QNAP Container Station status
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Last Updated**: 2026-03-19
|
||||||
|
**Version**: LCBP3-DMS v1.8.1
|
||||||
Reference in New Issue
Block a user