Step 12: Deployment and Production
What You'll Learn
- Build your application for production
- Configure essential environment variables
- Run your application in production mode
- Complete the production deployment checklist
What You'll Build
A production-ready NoEgo application deployed to the cloud.
Building for Production
Compile your TypeScript and prepare assets for production:
npm run buildThis creates a dist/ directory with compiled JavaScript and optimized assets.
Understanding the dist/ Output
After building, your dist/ directory contains the production-ready application:
dist/
├── no_ego.js # Production bootstrap (runs backend + frontend)
├── src/
│ ├── server/ # Compiled server code + SQL files
│ ├── ui/ # Compiled frontend TS/JS (mirrors source tree)
│ └── middleware/ # Compiled middleware
├── .app/
│ ├── assets/ # Client bundle (Vite output)
│ └── ssr/ # SSR bundle (Forge output)
├── src/server/openapi/ # Copied API OpenAPI + stitch files
└── src/ui/openapi/ # Copied UI OpenAPI + stitch filesThe compiled output is optimized for Node.js and ready to run without any additional build step.
Environment Variables
Configure your application for production using these essential environment variables:
# Required for production
NODE_ENV=production
# Server configuration
PORT=3000
# Security - REQUIRED: Set a strong secret for session cookies
COOKIE_SECRET=your-strong-secret-key-here
# Database
DATABASE_PATH=./data/production.sqlite
# Logging
LOG_LEVEL=infoImportant: COOKIE_SECRET
The COOKIE_SECRET is used to sign session cookies and should be a long,
random string. In production, generate it using: openssl rand -base64 32
Access environment variables in your application configuration:
export const config = {
port: Number(process.env.PORT) || 3000,
database: process.env.DATABASE_PATH || "./data/app.sqlite",
cookieSecret: process.env.COOKIE_SECRET || "dev-secret-change-in-production",
logLevel: process.env.LOG_LEVEL || "debug",
isProduction: process.env.NODE_ENV === "production",
};Running in Production
Start your application in production mode with the following command:
NODE_ENV=production node dist/no_ego.jsFor a more robust setup, use a process manager like PM2:
# Install PM2 globally
npm install -g pm2
# Start with PM2
pm2 start dist/no_ego.js --name "my-noego-app"
# View logs
pm2 logs my-noego-app
# Restart on file changes (useful for staging)
pm2 restart my-noego-appProduction Checklist
Before deploying to production, ensure you've completed these steps:
- ✓ Environment Variables: All required variables are set (NODE_ENV, PORT, COOKIE_SECRET)
- ✓ Database Migrations: Run
npx proper upbefore starting - ✓ Build Verification:
npm run buildcompletes without errors - ✓ Static Assets:
dist/.app/assetsis present and served viadist/no_ego.js - ✓ Database Backups: Backup strategy is configured
- ✓ Logging: Production logging is enabled for monitoring
- ✓ Security: COOKIE_SECRET is a strong, unique value
Docker Deployment
Create a Dockerfile for containerized deployment:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist
COPY migrations ./migrations
COPY proper.json ./
ENV NODE_ENV=production
EXPOSE 3000
CMD ["node", "dist/no_ego.js"]# Build the image
docker build -t my-noego-app .
# Run the container
docker run -p 3000:3000 \
-e COOKIE_SECRET=your-secret-here \
-v $(pwd)/data:/app/data \
my-noego-appPlatform Deployment
NoEgo applications can be deployed to any Node.js hosting platform:
- Railway: Connect your GitHub repo for automatic deployments
- Fly.io: Use their CLI with
fly launch - DigitalOcean: App Platform supports Node.js directly
- AWS/GCP: Use container services or serverless options
Monitoring in Production
Add proper logging for production monitoring:
import type { Request, Response, NextFunction } from "express";
export default function requestLogger(req: Request, res: Response, next: NextFunction) {
const start = Date.now();
res.on("finish", () => {
const duration = Date.now() - start;
console.log(`${req.method} ${req.originalUrl} - ${res.statusCode} (${duration}ms)`);
});
next();
}Congratulations!
You've completed the NoEgo tutorial!
What You Built
Over these 12 steps, you've created a full-stack application with:
- ● Project scaffolding and structure
- ● Svelte 5 UI with runes ($state, $props)
- ● OpenAPI routing with Forge
- ● Database migrations with Proper
- ● Type-safe queries with SQLStack
- ● Repository → Service → Controller architecture
- ● API endpoints with validation
- ● Frontend integration with page loaders
- ● Form handling and data mutations
- ● Production-ready deployment
Next Steps
Ready to build more? Here are some ideas to extend your application:
- → Add User Authentication: Implement login, registration, and session management
- → Implement Real-time Updates: Add WebSocket support for live data
- → Add File Upload Support: Allow users to upload images and files
- → Explore Advanced SQLStack: Learn about joins, transactions, and complex queries
Dive deeper into the framework with our comprehensive documentation.