Skip to content

Deployment Guide

Quick Reference

  • Platform: Docker (Node 20 + Nginx Alpine)
  • Port: 80 (Nginx)
  • CI/CD: GitHub Actions (build + test)
  • Package Manager: Bun (dev) / npm (CI)
  • Build Output: dist/boxme-insight/browser

System Requirements

ComponentMinimumRecommended
Node.js18.x20.x
npm9.x10.x
Bun (optional)1.0+Latest
RAM (build)2 GB4 GB
Disk500 MB1 GB

Environment Variables

VariableMô tảRequiredDefault
productionChế độ productionYesfalse
demoModeBật mock data (không gọi API)Notrue (dev), false (prod)
apiBaseUrlURL backend APIYeshttps://insights.omisell.com
globalLoginUrlURL trang login parent appYeshttps://oms.boxme.asia/login
globalLogoutUrlURL trang logoutYeshttps://oms.boxme.asia/logout
tokenStorageKeyKey lưu token trong localStorageNoboxme_insight_token

Source: (src/environments/environment.ts:1-8), (src/environments/environment.prod.ts:1-8)

WARNING

Đảm bảo demoMode = false trong production. Demo mode sẽ trả mock data thay vì gọi API thật.

Local Development Setup

bash
# Clone repository
git clone <repo-url>
cd boxme-insight

# Install dependencies
npm install

# Start dev server (port 4200)
npm start
# → http://localhost:4200
bash
# Install dependencies (faster)
bun install

# Start dev server
bun run start
# → http://localhost:4200

TIP

Dev server chạy ở demoMode=true mặc định — không cần backend. Để test với backend thật, sửa src/environments/environment.ts: demoMode: false.

Build Production

bash
# Build production bundle
npm run build -- --configuration=production

# Output directory
ls dist/boxme-insight/browser/

Build output là static files (HTML/CSS/JS), serve bằng bất kỳ web server nào.

Docker Deployment

Dockerfile (Multi-stage Build)

dockerfile
# Stage 1: Build Angular app
FROM node:20-alpine as build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build --configuration=production

# Stage 2: Serve with Nginx
FROM nginx:alpine
COPY --from=build /app/dist/boxme-insight/browser /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

Source: (Dockerfile:1-26)

Build & Run

bash
# Build Docker image
docker build -t boxme-insight .

# Run container
docker run -d -p 8080:80 --name boxme-insight boxme-insight

# Verify
curl http://localhost:8080
Nginx Configuration (Optional)

Nếu cần custom Nginx config (SPA routing, gzip, headers):

nginx
server {
    listen 80;
    server_name _;
    root /usr/share/nginx/html;
    index index.html;

    # SPA fallback — Angular routes
    location / {
        try_files $uri $uri/ /index.html;
    }

    # Gzip compression
    gzip on;
    gzip_types text/plain text/css application/json application/javascript;

    # Cache static assets
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
}

CI/CD Pipeline

GitHub Actions

Source: (.github/workflows/ci.yml:1-34)

TriggerBranches
Pushmain, develop
Pull Requestmain, develop
StepCommandMô tả
Checkoutactions/checkout@v4Clone repo
Setup Nodeactions/setup-node@v4Node 20.x + npm cache
Installnpm ciInstall exact versions
Buildnpm run buildProduction build
Testnpm test -- --watch=falseRun Vitest

Testing

bash
# Run unit tests (Vitest)
npm test

# Run tests once (CI mode)
npm test -- --watch=false

Monitoring & Health

EndpointMô tảExpected
http://host:80/App entry point200 OK + HTML
http://host:80/assets/Static assets200 OK

INFO

App hiện chưa có dedicated health check endpoint. Nginx sẽ trả 200 cho / nếu static files được serve đúng.

Liên kết

Hệ thống tài liệu Boxme AI Insight — Powered by CodyMaster DocKit