5.9 KiB
Deployment Guide
This Astro application is configured for SSR (Server-Side Rendering) deployment using the Node.js adapter.
📋 Domain Migration: For domain migration from workroot.com to workroot.in, see
DOMAIN-MIGRATION-CHECKLIST.mdandMIGRATION-SUMMARY.md
Server Configuration
The application is configured to run with the following settings:
- Host:
0.0.0.0(accepts connections from all network interfaces) - Port:
10000(configurable viaPORTenvironment variable)
Quick Start
1. Install Dependencies
npm install
2. Build the Application
npm run build
This will generate the production build in the dist/ directory with:
dist/server/- Server-side code and SSR entry pointdist/client/- Static assets and client-side JavaScript
3. Start the Production Server
npm start
The server will start on http://0.0.0.0:10000
Environment Variables
Create a .env file in the root directory to customize the server configuration:
# Server host (default: 0.0.0.0)
HOST=0.0.0.0
# Server port (default: 10000)
PORT=10000
# Node environment
NODE_ENV=production
Production Deployment Options
Option 1: Docker Deployment
Create a Dockerfile:
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy built application
COPY dist ./dist
COPY server.mjs ./
# Expose port
EXPOSE 10000
# Set environment
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=10000
# Start server
CMD ["node", "server.mjs"]
Build and run:
docker build -t workroot-website .
docker run -p 10000:10000 workroot-website
Option 2: PM2 Process Manager
Install PM2 globally:
npm install -g pm2
Create ecosystem.config.cjs:
module.exports = {
apps: [{
name: 'workroot-website',
script: './server.mjs',
instances: 'max',
exec_mode: 'cluster',
env: {
NODE_ENV: 'production',
HOST: '0.0.0.0',
PORT: 10000
}
}]
};
Start with PM2:
pm2 start ecosystem.config.cjs
pm2 save
pm2 startup # Enable auto-start on system boot
Option 3: Direct Node.js
NODE_ENV=production node server.mjs
Platform-Specific Deployments
Render.com
- Connect your repository
- Set build command:
npm run build - Set start command:
npm start - Set environment variable:
PORT=10000
Railway.app
- Connect your repository
- Railway will auto-detect the build and start commands
- The app will automatically use the
PORTenvironment variable
DigitalOcean App Platform
- Create a new app from your repository
- Set build command:
npm run build - Set run command:
npm start - Configure port:
10000
VPS (Ubuntu/Debian)
# Install Node.js 20
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Clone repository
git clone <your-repo-url>
cd workroot-website
# Install dependencies and build
npm ci --only=production
npm run build
# Install PM2
sudo npm install -g pm2
# Start with PM2
pm2 start server.mjs --name workroot-website
pm2 save
pm2 startup
# Setup nginx reverse proxy (optional)
sudo apt install nginx
Nginx configuration (/etc/nginx/sites-available/workroot):
server {
listen 80;
server_name workroot.in www.workroot.in;
return 301 https://workroot.in$request_uri;
}
server {
listen 443 ssl http2;
server_name workroot.in;
ssl_certificate /etc/letsencrypt/live/workroot.in/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/workroot.in/privkey.pem;
# Security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
location / {
proxy_pass http://localhost:10000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Health Check
The server includes graceful shutdown handlers for SIGTERM and SIGINT signals.
You can verify the server is running by accessing:
http://localhost:10000(local)http://0.0.0.0:10000(all interfaces)
Performance Optimization
The application includes:
- ✅ Image optimization with Sharp (WebP conversion)
- ✅ HTML compression
- ✅ CSS code splitting
- ✅ Manual chunk splitting for better caching
- ✅ Lazy loading for images
- ✅ Prefetch with viewport strategy
Security Considerations
- Always use HTTPS in production (use a reverse proxy like nginx)
- Set proper CORS headers if serving APIs
- Keep dependencies updated:
npm audit fix - Use environment variables for sensitive configuration
- Enable rate limiting for API endpoints
- Set proper CSP headers
Monitoring
Consider adding monitoring tools:
- PM2 Plus: For production monitoring
- New Relic: Application performance monitoring
- Sentry: Error tracking
- LogDNA/Datadog: Log aggregation
Troubleshooting
Port already in use
# Find process using port 10000
lsof -i :10000 # macOS/Linux
netstat -ano | findstr :10000 # Windows
# Kill the process
kill -9 <PID>
Server not accessible
- Verify firewall rules allow port 10000
- Check that HOST is set to
0.0.0.0for external access - Ensure the build completed successfully
Static assets not loading
- Verify
dist/client/directory exists - Check that the server.mjs is in the project root
- Ensure build command ran successfully