If you want to figure out your hosting solution completely from scratch, the Meteor tool has a commandDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/meteor/meteor/llms.txt
Use this file to discover all available pages before exploring further.
meteor build that creates a deployment bundle containing a plain Node.js application.
This approach gives you complete control over your deployment infrastructure but requires more manual setup and maintenance compared to managed solutions.
Building Your Application
Themeteor build command creates a deployment bundle that can run on any server with Node.js and MongoDB.
Prerequisites
Before building, ensure all npm dependencies are installed:Build Command
Create a production bundle for deployment:It’s important that you build your bundle for the correct architecture. For example, if deploying to a Ubuntu Linux server, use
os.linux.x86_64.Build Options
--architecture- Specify the target architecture (e.g.,os.linux.x86_64)--directory- Build to a directory instead of a tarball--server-only- Don’t build mobile apps--server- Set the ROOT_URL (for mobile builds)
Understanding the Bundle
Themeteor build command produces a .tar.gz file containing:
bundle/- The application bundle directorymain.js- Application entry pointprograms/- Server and client codeserver/- Server-side code and npm dependenciesweb.browser/- Client-side code
.node_version.txt- Required Node.js versionstar.json- Bundle metadata
Deployment Steps
Required Environment Variables
Your Meteor application requires these environment variables to run:ROOT_URL
The base URL for your Meteor project:MONGO_URL
A MongoDB connection string URI:PORT
The port at which the application is running:METEOR_SETTINGS (Optional)
Settings as a stringified JSON object:Node.js Version
The environment you choose will need the correct version of Node.js and connectivity to a MongoDB server. To find out which version of Node you should use:- Run
meteor node -vin the development environment - Check the
.node_version.txtfile within the bundle - For Meteor 3.x, you’ll need Node.js 20.x
Example Deployment Script
Here’s a complete deployment script you can adapt:deploy.sh
Process Management
For production deployments, use a process manager to keep your application running:PM2
PM2 is a popular Node.js process manager:Systemd Service
Alternatively, create a systemd service:/etc/systemd/system/meteor-app.service
Reverse Proxy Setup
For production deployments, use a reverse proxy like Nginx to:- Handle SSL/TLS termination
- Serve static files efficiently
- Load balance across multiple instances
- Add security headers
Nginx Configuration
/etc/nginx/sites-available/meteor-app
Meteor Up Alternative
Meteor Up (mup) is a third-party, open-source tool that automates the manual steps of usingmeteor build and deploying to your server.
Meteor Up can SSH into any server running Ubuntu or Debian and handle the deployment process for you.
Get started with the Meteor Up tutorial.
Key Features
- Automated deployment via SSH
- Docker-based deployments
- Zero-downtime deployments
- SSL certificate management
- MongoDB setup and management
- Environment variable management
- Deployment rollback support
AWS Elastic Beanstalk Plugin
The mup-aws-beanstalk plugin deploys Meteor apps to AWS Elastic Beanstalk instead of a server. It supports:- Autoscaling
- Load balancing
- Zero downtime deploys
- Managed infrastructure
Best Practices
Use Process Managers
Use Process Managers
Always use a process manager like PM2 or systemd to ensure your application restarts automatically on crashes or server reboots.
Implement Reverse Proxy
Implement Reverse Proxy
Use Nginx or similar reverse proxy for SSL termination, static file serving, and additional security.
Build for Correct Architecture
Build for Correct Architecture
Always specify the correct architecture when building to avoid runtime errors.
Version Control Deployments
Version Control Deployments
Keep track of deployed versions and maintain deployment scripts in version control.
Monitor Application Health
Monitor Application Health
Implement health checks and monitoring to detect issues early.
Backup MongoDB Regularly
Backup MongoDB Regularly
Set up automated MongoDB backups to prevent data loss.
Troubleshooting
Build Errors
- Ensure all npm dependencies are installed before building
- Check that you have enough disk space for the build
- Verify you’re using a supported Node.js version
Runtime Errors
- Check that all environment variables are set correctly
- Verify MongoDB is accessible and credentials are correct
- Ensure the Node.js version matches the one used to build
- Check application logs for specific error messages
Connection Issues
- Verify firewall rules allow traffic on the specified port
- Check that reverse proxy is properly configured
- Ensure WebSocket connections are supported
- Verify ROOT_URL matches the actual domain
Performance Issues
- Use a production MongoDB with proper indexing
- Implement caching strategies
- Configure CDN for static assets
- Use WebAppInternals.setBundledJsCssPrefix() for CDN
- Monitor resource usage (CPU, memory, disk)