Go API Proxy ได้ถูก deploy ด้วย Docker Compose เรียบร้อยแล้ว
docker-compose up -ddocker-compose psdocker-compose logs -fdocker-compose down| Variable | Value | Description |
|---|---|---|
BACKEND_HOST |
https://exp.co2e.cc |
Backend API URL |
PORT |
80 |
Server port |
WHITELIST_FILE |
whitelist.json |
Token whitelist file |
HTTP_TIMEOUT |
30 |
HTTP timeout (seconds) |
curl http://localhost/health
# Response: {"status":"healthy","service":"go-api-proxy"}curl http://localhost/api/v2/tokens
# Returns filtered tokens based on whitelist- แก้ไขไฟล์
whitelist.json - ไม่ต้อง restart container (อัปเดตอัตโนมัติ)
# Start development (port 8080)
docker-compose -f docker-compose.dev.yml up -d
# View dev logs
docker-compose -f docker-compose.dev.yml logs -f
# Stop dev environment
docker-compose -f docker-compose.dev.yml down# Start production with advanced features
docker-compose -f docker-compose.prod.yml up -d
# View production logs
docker-compose -f docker-compose.prod.yml logs -fmake up # Start production
make dev # Start development
make logs # View logs
make down # Stop services
make clean # Clean up everythingdocker-compose psdocker stats go-api-proxy# Manual health check
curl -f http://localhost/health
# Automated monitoring script
while true; do
if curl -f http://localhost/health > /dev/null 2>&1; then
echo "$(date): Service is healthy"
else
echo "$(date): Service is down"
fi
sleep 30
done# ดู logs
docker-compose logs go-api-proxy
# Restart container
docker-compose restart go-api-proxy# เปลี่ยน port ใน docker-compose.yml
ports:
- "8080:80" # ใช้ port 8080 แทน# ตรวจสอบ backend connectivity
curl https://exp.co2e.cc/api/v2/tokens
# เปลี่ยน backend ใน docker-compose.yml
environment:
BACKEND_HOST: "https://your-backend-api.com"- Container ทำงานด้วย non-root user (appuser:1001)
- Whitelist file เป็น read-only mount
- Health check endpoint พร้อมใช้งาน
- Resource limits ถูกกำหนดไว้แล้ว
- Production Setup: ใช้
docker-compose.prod.ymlสำหรับ production - SSL/TLS: เพิ่ม nginx reverse proxy สำหรับ HTTPS
- Monitoring: ตั้งค่า monitoring และ alerting
- Backup: สำรองข้อมูล whitelist และ configuration
- CI/CD: ตั้งค่า automated deployment pipeline
Go API Proxy พร้อมใช้งานแล้วที่ http://localhost
- ✅ Docker Compose deployment
- ✅ Environment variables configuration
- ✅ Health checks
- ✅ Token filtering
- ✅ Logging และ monitoring
- ✅ Graceful shutdown