Deployment Guide
Deployment Guide
Section titled “Deployment Guide”Guide for building and deploying IONFLOW Frontend to various environments.
Build Process
Section titled “Build Process”Production Build
Section titled “Production Build”# Build for productionpnpm build
# Preview the build locallypnpm previewBuild Output
Section titled “Build Output”The build outputs to dist/:
dist/├── assets/│ ├── index-[hash].js # Main bundle│ ├── index-[hash].css # Styles│ └── [chunks]-[hash].js # Code-split chunks├── static/│ └── img/ # Static images├── index.html└── favicon.icoEnvironment-Specific Builds
Section titled “Environment-Specific Builds”# Developmentpnpm build --mode development
# Stagingpnpm build --mode staging
# Productionpnpm build --mode productionEnvironment Variables
Section titled “Environment Variables”Build-Time Variables
Section titled “Build-Time Variables”Variables are replaced at build time:
VITE_API_URL=https://api.ionflow.com/apiVITE_KEYCLOAK_URL=https://auth.ionflow.comVITE_ENABLE_DEV_TOOLS=falseRuntime Configuration
Section titled “Runtime Configuration”For runtime configuration, use a config endpoint or inject variables:
// Load config at runtimeconst config = await fetch('/config.json').then(r => r.json());Deployment Options
Section titled “Deployment Options”Static Hosting
Section titled “Static Hosting”The build output is static and can be hosted on:
- Nginx
- Apache
- AWS S3 + CloudFront
- Netlify
- Vercel
- GitHub Pages
Nginx Configuration
Section titled “Nginx Configuration”server { listen 80; server_name app.ionflow.com; root /var/www/ionflow; index index.html;
# Gzip compression gzip on; gzip_types text/plain text/css application/json application/javascript;
# Cache static assets location /assets { expires 1y; add_header Cache-Control "public, immutable"; }
# SPA fallback location / { try_files $uri $uri/ /index.html; }
# API proxy location /api { proxy_pass http://backend:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; }}Docker
Section titled “Docker”# DockerfileFROM node:20-alpine AS build
WORKDIR /appCOPY package.json pnpm-lock.yaml ./RUN npm install -g pnpm && pnpm install
COPY . .ARG VITE_API_URLARG VITE_KEYCLOAK_URLRUN pnpm build
FROM nginx:alpineCOPY --from=build /app/dist /usr/share/nginx/htmlCOPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80CMD ["nginx", "-g", "daemon off;"]version: '3.8'services: frontend: build: context: . args: VITE_API_URL: ${VITE_API_URL} VITE_KEYCLOAK_URL: ${VITE_KEYCLOAK_URL} ports: - "80:80" environment: - NODE_ENV=productionKubernetes
Section titled “Kubernetes”apiVersion: apps/v1kind: Deploymentmetadata: name: ionflow-frontendspec: replicas: 3 selector: matchLabels: app: ionflow-frontend template: metadata: labels: app: ionflow-frontend spec: containers: - name: frontend image: ionflow/frontend:latest ports: - containerPort: 80 resources: limits: cpu: "100m" memory: "128Mi"---apiVersion: v1kind: Servicemetadata: name: ionflow-frontendspec: selector: app: ionflow-frontend ports: - port: 80 targetPort: 80GitHub Actions
Section titled “GitHub Actions”name: Deploy
on: push: branches: [main]
jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
- name: Setup Node uses: actions/setup-node@v3 with: node-version: 20
- name: Setup pnpm uses: pnpm/action-setup@v2 with: version: 8
- name: Install dependencies run: pnpm install
- name: Run tests run: pnpm test:unit
- name: Build env: VITE_API_URL: ${{ secrets.API_URL }} VITE_KEYCLOAK_URL: ${{ secrets.KEYCLOAK_URL }} run: pnpm build
- name: Deploy to S3 uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-1
- run: aws s3 sync dist/ s3://ionflow-frontend --delete
- name: Invalidate CloudFront run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DIST_ID }} --paths "/*"Performance Optimization
Section titled “Performance Optimization”Build Optimization
Section titled “Build Optimization”export default defineConfig({ build: { // Enable minification minify: 'terser',
// Chunk splitting rollupOptions: { output: { manualChunks: { vendor: ['vue', 'vue-router', 'pinia'], primevue: ['primevue'], }, }, },
// Source maps for production debugging sourcemap: true, },});Caching Strategy
Section titled “Caching Strategy”| Resource | Cache Duration | Strategy |
|---|---|---|
| HTML | No cache | Always fetch |
| JS/CSS (hashed) | 1 year | Immutable |
| Images | 1 week | Stale-while-revalidate |
| Fonts | 1 year | Immutable |
CDN Configuration
Section titled “CDN Configuration”# CloudFront behaviors/assets/* - Cache 1 year, gzip/static/* - Cache 1 week, gzip/index.html - No cache/* - Forward to originMonitoring
Section titled “Monitoring”Health Checks
Section titled “Health Checks”location /health { return 200 'OK'; add_header Content-Type text/plain;}Error Tracking
Section titled “Error Tracking”import * as Sentry from '@sentry/vue';
if (import.meta.env.PROD) { Sentry.init({ app, dsn: import.meta.env.VITE_SENTRY_DSN, environment: import.meta.env.MODE, });}Rollback Strategy
Section titled “Rollback Strategy”Blue-Green Deployment
Section titled “Blue-Green Deployment”- Deploy new version to “green” environment
- Test green environment
- Switch traffic from “blue” to “green”
- Keep blue available for rollback
Version Tagging
Section titled “Version Tagging”# Tag releasegit tag v1.2.3git push origin v1.2.3
# Build specific versiondocker build -t ionflow/frontend:v1.2.3 .Checklist
Section titled “Checklist”Pre-Deployment
Section titled “Pre-Deployment”- All tests pass
- Build succeeds
- Environment variables configured
- Version tagged
Post-Deployment
Section titled “Post-Deployment”- Application loads correctly
- Authentication works
- API calls succeed
- No console errors
- Monitoring alerts configured