mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-25 06:04:54 +00:00
2.2 KiB
2.2 KiB
Deployment Guide
Simplified Docker Setup
The application now uses a simplified single-stage Docker build with Vite's preview server instead of nginx. This eliminates the complexity and glitches associated with the multi-stage nginx deployment.
Benefits
- Simpler: Single-stage build, no nginx configuration needed
- Smaller: Alpine-based image (~100MB smaller)
- More reliable: Vite preview server handles routing correctly by default
- Faster builds: No multi-stage copying overhead
- Better for SPA: Vite preview understands React Router automatically
CapRover Deployment
Quick Deploy
-
Build and push your image:
docker build -t your-registry/codeforge:latest . docker push your-registry/codeforge:latest -
In CapRover, create a new app and deploy using the image
-
CapRover will automatically map port 80
Environment Variables
The app respects the PORT environment variable, which CapRover sets automatically:
- Default:
80 - CapRover will override this as needed
Build Notes
- The Dockerfile uses
npm ci --omit=devto install only production dependencies after the build - Console logs are stripped in production via terser
- Assets are served with proper routing via Vite's preview server
Local Testing
Test the production build locally:
# Build the app
npm run build
# Preview (simulates production)
npm run preview
# Or with custom port
PORT=3000 npm run preview
Why This Works Better
The previous nginx setup had these issues:
- Required maintaining separate nginx configuration
- Multi-stage build complexity
- Asset path resolution issues with React Router
- Health check endpoint needs custom nginx config
The Vite preview server:
- Built-in SPA routing support
- Handles all asset paths correctly
- Production-ready and officially supported
- Simpler configuration via vite.config.ts
Troubleshooting
If you still experience issues:
- Check the base path: Ensure
base: './'in vite.config.ts - Verify port: CapRover should set PORT env var automatically
- Check logs: Use CapRover's log viewer to see startup issues
- Test locally: Run
npm run build && npm run previewto verify the build