Deploying a MeteorJS App
MeteorJS is a full-stack JavaScript platform for building modern web and mobile applications. It provides an integrated solution with a powerful build system, real-time data synchronization, and a rich ecosystem of packages, making it easy to develop and deploy robust applications quickly.
This guide explains how to deploy a MeteorJS application to Klutch.sh, both with and without a Dockerfile. It also covers installation and provides sample code to get started.
Prerequisites
- Node.js and npm installed
- Git and GitHub account
- Klutch.sh account
Getting Started: Install MeteorJS
- Install MeteorJS globally:
Terminal window curl https://install.meteor.com/ | sh - Create a new MeteorJS app:
Terminal window meteor create my-meteor-appcd my-meteor-app - Start the development server:
Your app should be running at http://localhost:3000.
Terminal window meteor
Sample Code (main.js)
Meteor creates a sample app for you. The main entry point is usually server/main.js
.
import { Meteor } from 'meteor/meteor';
Meteor.startup(() => { // code to run on server at startup});
Deploying Without a Dockerfile
- Push your MeteorJS app to a GitHub repository.
- Log in to Klutch.sh.
- Create a new project and give it a name.
- Create a new app:
- Select your MeteorJS GitHub repository and branch
- Set the port to route traffic (usually 3000 for MeteorJS)
- Choose region, compute, number of instances, and add any environment variables
- Add a start script in your
package.json
(if not present):"scripts": {"start": "meteor run"} - Click “Create” to deploy. Klutch.sh will build and deploy your app automatically.
Deploying With a Dockerfile
- Add a
Dockerfile
to your project root. Example:# Use official Meteor base imageFROM meteor/meteor-base:2.14.1# Set working directoryWORKDIR /app# Copy app sourceCOPY . .# Install dependencies and build Meteor appRUN meteor npm install --productionRUN meteor build --directory /app/build# Expose port (match your MeteorJS app)EXPOSE 3000# Start the appCMD ["meteor", "run", "--port", "3000"] - Push your code (with Dockerfile) to GitHub.
- In Klutch.sh, follow the same steps to create a project and app, but select the Dockerfile option when prompted.
- Set the service details and environment variables as needed.
- Click “Create” to deploy. Klutch.sh will build your Docker image and deploy your app.
Note: If you use a custom port, ensure it matches the port provided by Klutch.sh via the PORT
environment variable.
Resources
Deploying to Klutch.sh is simple and flexible. Choose the method that best fits your workflow and project requirements.