Files
pos-system/docs/vi/guides/deployment.md
Ho Ngoc Hai b104fafa85 Refactor auth-service to iam-service and update related documentation
- Renamed auth-service to iam-service across various files for consistency.
- Updated Dockerfiles, deployment configurations, and documentation to reflect the service name change.
- Enhanced testing commands in documentation to point to the new iam-service.
- Removed outdated auth-service files and configurations to streamline the project structure.
- Improved bilingual documentation for clarity on the new service structure and usage.
2025-12-30 20:54:21 +07:00

2.7 KiB

Hướng Dẫn Deployment

Thiết Lập Database (Neon)

Tất cả môi trường sử dụng Neon PostgreSQL. Thiết lập một lần trước khi deploy:

  1. Tạo Neon project tại https://neon.tech
  2. Tạo branches: main (dev), staging, production
  3. Lấy connection strings cho mỗi branch
  4. Cấu hình trong environment variables (xem bên dưới)

Xem Hướng Dẫn Thiết Lập Neon để biết chi tiết.

Local Deployment

# Setup Neon database URL
cp deployments/local/env.local.example deployments/local/.env.local
# Chỉnh sửa .env.local và thêm Neon DATABASE_URL của bạn

# Khởi động services (không cần PostgreSQL container)
cd deployments/local
docker-compose up -d

Staging Deployment

Yêu Cầu

  • Quyền truy cập Kubernetes cluster
  • kubectl đã cấu hình
  • KUBECONFIG đã set
  • Neon staging branch đã tạo
  • GitHub Secrets đã cấu hình:
    • NEON_DATABASE_URL_STAGING
    • KUBECONFIG_STAGING

Thiết Lập Secrets

# Tạo Kubernetes secret
kubectl create secret generic iam-service-secrets \
  --from-literal=database-url='postgresql://user:pass@ep-xxx.region.neon.tech/dbname?sslmode=require&pgbouncer=true' \
  --from-literal=jwt-secret='your-staging-jwt-secret' \
  --from-literal=jwt-refresh-secret='your-staging-refresh-secret' \
  -n staging

Deploy

./scripts/deploy/deploy-staging.sh

Hoặc thủ công:

kubectl apply -f deployments/staging/kubernetes/

Lưu ý: Migrations chạy tự động trong CI/CD trước khi deployment.

Production Deployment

Yêu Cầu

  • Production Kubernetes cluster
  • kubectl đã cấu hình với production context
  • Neon production branch đã tạo
  • GitHub Secrets đã cấu hình:
    • NEON_DATABASE_URL_PRODUCTION
    • KUBECONFIG_PRODUCTION

Thiết Lập Secrets

# Tạo Kubernetes secret
kubectl create secret generic iam-service-secrets \
  --from-literal=database-url='postgresql://user:pass@ep-xxx.region.neon.tech/dbname?sslmode=require&pgbouncer=true' \
  --from-literal=jwt-secret='your-production-jwt-secret' \
  --from-literal=jwt-refresh-secret='your-production-refresh-secret' \
  -n production

Deploy

./scripts/deploy/deploy-prod.sh

Lưu ý: Migrations chạy tự động trong CI/CD trước khi deployment (cần approval).

Rollback

kubectl rollout undo deployment/iam-service -n production

Health Checks

  • Liveness: GET /health/live
  • Readiness: GET /health/ready
  • Health: GET /health

Monitoring