|
1 | | -# Deployment Guide |
| 1 | +# DIMO Build Developer Kit |
2 | 2 |
|
3 | | -## Production Build and Deployment |
| 3 | +## Overview |
4 | 4 |
|
5 | | -### Prerequisites |
6 | | -Before deploying, ensure you have: |
7 | | -1. Built the application for production |
8 | | -2. Set up static file serving correctly |
9 | | -3. Configured environment variables |
| 5 | +This is a Replit template for running an app that integrates [Login with DIMO](https://www.npmjs.com/package/@dimo-network/login-with-dimo) and [DIMO Data SDK](https://www.npmjs.com/package/@dimo-network/data-sdk). |
10 | 6 |
|
11 | | -### Building for Production |
| 7 | +## Quick Start |
12 | 8 |
|
13 | | -Run the production build script: |
14 | | -```bash |
15 | | -./build-production.sh |
16 | | -``` |
17 | | - |
18 | | -This script will: |
19 | | -1. Run `npm run build` to build both the client and server |
20 | | -2. Create the `server/public` directory |
21 | | -3. Copy static files from `dist/public` to `server/public` |
| 9 | +1. Remix this Replite Template |
| 10 | +2. Update secrets with your own DIMO Developer License credentials, if you don't have these credentials, sign up on the [DIMO Developer Console](https://console.dimo.org): |
| 11 | + - Client ID: `DIMO_CLIENT_ID` & `VITE_DIMO_CLIENT_ID` |
| 12 | + - Redirect URI: `DIMO_REDIRECT_URI` & `VITE_DIMO_REDIRECT_URI` |
| 13 | + - API Key: `DIMO_API_KEY` |
22 | 14 |
|
23 | | -### Starting the Production Server |
| 15 | +## Deployment Configuration |
24 | 16 |
|
25 | | -#### Option 1: Using the startup script (Recommended) |
26 | | -```bash |
27 | | -./start-production.sh |
28 | | -``` |
| 17 | +### Production Build Process |
| 18 | +- **Build Script**: Custom `build-production.sh` script handles complete production build |
| 19 | +- **Static File Serving**: Fixed file path mismatch between build output (`dist/public`) and server expectations (`server/public`) |
| 20 | +- **Host Binding**: Server configured to bind to `0.0.0.0:5000` for proper interface access |
| 21 | +- **Environment Detection**: Automatic switching between development (Vite HMR) and production (static file serving) modes |
29 | 22 |
|
30 | | -#### Option 2: Manual startup |
31 | | -```bash |
32 | | -NODE_ENV=production node dist/index.js |
33 | | -``` |
34 | | - |
35 | | -### Key Deployment Fixes Applied |
36 | | - |
37 | | -1. **Static File Serving**: Fixed the mismatch between build output (`dist/public`) and expected location (`server/public`) |
38 | | -2. **Host Binding**: Server is configured to bind to `0.0.0.0:5000` for proper interface access |
39 | | -3. **Production Mode**: The server correctly serves static files in production using the `serveStatic` function |
40 | | -4. **ES Module Compatibility**: Created DIMO SDK wrapper to handle directory import issues |
41 | | -5. **Custom Build Process**: Updated esbuild configuration with proper externals and bundling |
42 | | -6. **Graceful Fallback**: DIMO SDK wrapper provides proper error handling and fallback behavior for production deployment |
43 | | - |
44 | | -### Environment Variables |
45 | | -- `PORT`: Server port (defaults to 5000) |
46 | | -- `NODE_ENV`: Set to "production" for production deployment |
47 | | - |
48 | | -### File Structure |
| 23 | +### Build Output Structure |
49 | 24 | ``` |
50 | 25 | ├── dist/ |
51 | | -│ ├── index.js # Built server |
52 | | -│ └── public/ # Built client files (Vite output) |
| 26 | +│ ├── index.js # Bundled server (ESBuild) |
| 27 | +│ └── public/ # Client build output (Vite) |
53 | 28 | ├── server/ |
54 | | -│ └── public/ # Static files for production serving |
55 | | -├── build-production.sh # Production build script |
56 | | -└── package.json |
| 29 | +│ └── public/ # Production static files location |
57 | 30 | ``` |
58 | 31 |
|
59 | | -### Troubleshooting |
60 | | -- If static files aren't served, ensure `server/public` exists and contains the built client files |
61 | | -- Verify the server is binding to `0.0.0.0` and not just `localhost` |
62 | | -- Check that `NODE_ENV=production` is set when running the production server |
| 32 | +### Deployment Requirements |
| 33 | +- Node.js runtime environment |
| 34 | +- Environment variable `NODE_ENV=production` |
| 35 | +- Port configuration via `PORT` environment variable (defaults to 5000) |
| 36 | +- Static files must be properly copied to `server/public` before starting production server |
| 37 | + |
| 38 | +## Source |
| 39 | +This template is based on the using DIMO's Developer SDKs. For more information, visit https://docs.dimo.org/developer-platform/developer-guide/dimo-developer-sdks |
0 commit comments