Docker Setup
0/3Dockerfile, ignore rules, image optimization
Dùng FROM node:20-alpine AS builder → FROM nginx:alpine để giảm image size production.
.dockerignore
Important
Loại trừ node_modules, .git, .env, dist để tránh copy file không cần thiết vào image.
Chạy docker images và verify size ≤ 50MB cho app thông thường. Dùng docker dive để phân tích layer.
GitHub Actions CI
0/3Workflow file, caching, test automation
.github/workflows/ci.yml
Required
Định nghĩa on: push/pull_request, jobs build và test chạy song song để tiết kiệm thời gian.
Dùng actions/setup-node với cache: 'npm' để cache node_modules, giảm 2-3 phút build time.
Thêm npm run test:coverage và upload kết quả lên Codecov hoặc GitHub Artifacts để track coverage trend.
Secrets Management
0/3Bảo mật API keys, environment variables
Vào Settings → Secrets and variables → Actions. Thêm DOCKER_TOKEN, DEPLOY_KEY, SENTRY_DSN.
Tạo environment production với required reviewers. Deploy lên production chỉ sau khi được approve thủ công.
.gitignore che đủ file nhạy cảm
Required
Đảm bảo .env, .env.local, *.pem, secrets/ đã được ignore. Dùng git-secrets để scan.
Preview Deployment
0/3Vercel / Netlify preview URL cho mỗi PR
Import project trên dashboard, cấu hình build command npm run build và output directory dist hoặc out.
Tạo một test PR và kiểm tra bot comment URL preview dạng app-git-branch.vercel.app trong vòng 2 phút.
Dùng treosh/lighthouse-ci-action để auto-check performance score trước khi merge, threshold ≥ 80.
Monitoring & Error Tracking
0/3Sentry integration, source maps, alerting
Cài @sentry/react hoặc @sentry/nextjs. Init với DSN từ GitHub Secret, bật tracesSampleRate: 0.1 cho production.
Thêm bước sentry-cli releases upload-sourcemaps vào workflow sau build. Đảm bảo SENTRY_AUTH_TOKEN có trong secrets.
Trigger test error thủ công bằng Sentry.captureException(new Error("test")) và xác nhận hiển thị trên Sentry dashboard với source map đúng.
Cost Optimization
0/3Tối ưu GitHub Actions minutes, caching
Dùng cache-from: type=gha và cache-to: type=gha,mode=max trong bước docker/build-push-action.
paths-filter để skip job không liên quan
Important
Dùng dorny/paths-filter — chỉ chạy test backend khi có thay đổi trong src/api/**, tránh lãng phí minutes.
Vào Settings → Billing → Actions. Xem minutes consumed, set spending limit. Free tier: 2,000 min/tháng cho private repos.