Deploying and maintaining your Meteor.js app on AWS is no easy task. As a developer, you have to ask, do you want to carry the burden of server management, security patches, database backups, backups integrity checks and disaster recovery planning on yourself in addition to developing your Meteor.js app. Knowning very well, your end users only see your app and not what goes on behind the scenes and expect it to work all the time. We believe the developer should spend their time focused solely on their app and leave the DevOps side of things to the experts at NodeChef.
Enter NodeChef Platform-as-a-Service for AWS. A self service platform allowing you to deploy Meteor.js the right way to your EC2 Servers. NodeChef reduces deploying Meteor.js applications to running a single "nodechef deploy" or "git push" command.
We will go over the below steps to demonstrate how to host Meteor.js on AWS using NodeChef Platform-as-a-Service. A robust managed AWS cloud hosting platform for applications of all sizes and scope. You do not require any prior windows or linux server management expertise to successfully complete this tutorial. NodeChef takes care of everything so you can focus on your code.
- Create a NodeChef account and connect your EC2 Server
- Push your Meteor.js app to the EC2 Server
- We Install Meteor.js and other packages on your server and launch your Meteor.js app
Steps to Deploy Meteor.js on your EC2 Server
Step 1: Create a NodeChef account and connect your EC2 server.
Sign up for a NodeChef account, confirm your email address and log into the dashboard. You can also quickly log in and skip the sign up if you have an account with Google, GitLab, GitHub or BitBucket.
On the dashboard, click private cloud → add new server. Before you can add your EC2 Server, you must ensure your server meets the below criteria. We advice you use a new EC2 Server which you are not already using. Of course you can still use the EC2 Server for other projects and not just the Meteor.js app.Checklist:
- Public Ipv4 address.
- A login user with sudo privilege.
- The private key or the password to be used to log into the server.
- Server runs Ubuntu OS (18.x, 20.x or later). NodeChef prefers 20.0.4 - focal. Ubuntu 16 is fine too although we do not recommend it.
- CPU architecture is X86_X64.
- Server has at least 15 GB storage.
- You must ensure inbound traffic to ports 22, 80, 443, and port range 3000 - 6000 are allowed. For a start, simply allow all TCP traffic on the security group of the EC2 server.
You can also integrate your AWS account with NodeChef and provision EC2 servers directly from the NodeChef dashboard. NodeChef ensures the checklist is met automatically. In this tutorial, we will provision the EC2 server on AWS and bring it to NodeChef.
Enter the details on the add server form and then click the add server button to add it to your NodeChef account. Adding a new server can take up to 10 minutes to set it up with all the runtime tools that will allow NodeChef to manage Meteor.js deployments to your server.
Once you click Add server, you can see the progress of the NodeChef runtime installation on your EC2 server as seen below:
Step 2: Push your Meteor.js app to the server.
Now that the server has been added to your NodeChef account, it's time to push the code to the EC2 Server. Before deploying your Meteor.js app, you have to make sure it is ready to run in an environment other than your local computer.
Pushing Meteor.js apps is simple, there are no special undertaking required before you can push the app. We provide two different ways to deploy Meteor.js which is explained below.
NodeChef provides first class support for Meteor.js apps as such you can deploy with your settings.json file without having to perform any unneccessary hacks.
NodeChef will also configure the MONGO_URL and MONGO_OPLOG_URL automatically so your app can start and connect right away to the MongoDB database without any configuration on your end.
- First, setup a NodeChef application
Click on the deployments tab on the dashboard. under Deploy App. Specify a name for your app and select a container size You can simply select the largest container size since you own the EC2 Server and we do not bill by container size. Select MongoDB as the database for you app.
Under the hosting location, select the name of the project you used when adding the EC2 server under the host this application on my servers. This is very important
Click the launch cluster button to create the application on your EC2 server.
Push the code to the EC2 server
We provide two different ways for you to push your application to your server as explained below.
Push using GIT
Click on the Task Manager → App Actions → Git integration to configure GitLab, GitHub or BitBucket integration.
To configure GitLab integration, you have to authenticate with your Git repository. You only have to do this once per NodeChef account. Click “Connect to (repository)”, to start the authentication. If you signed up or logged in with GitHub, GitLab or BitBucket, the authorization step should be already complete without having to perform another authorization step.
After you link your Account to a Git repo, select the repository and branch to deploy to push manually. You can also configure a specific branch to automatically deploy whenever you run git push from your terminal.
When deploying via GIT, the BuildPack which handles Meteor.js apps will automatically pick up your settings.json file.
Deploying Meteor.js using the NodeChef CLI
Install the NodeChef CLI from npm using the command as seen below:
$ npm install -g nodechef-cli
Generate a deployment token from the dashboard by navigating to the task manager → App actions → Deployment token
CD into your project folder and use the command as seen below to deploy. You must replace "mymeteorapp" with the actual name of your app as you created it on NodeChef.
$ nodechef deploy -i mymeteorapp -auth my_token # To configure your meteor settings, # specify the path to the settings.json file $ nodechef deploy -i mymeteorapp -meteorsettings settings.json \ -auth my_token
You can read more on deploying Meteor.js using the NodeChef CLI here. You can set the CLI up in such a way that you only have to run nodechef deploy and that will automatically trigger a build and push your app.
Step 3: We Install Meteor.js and other packages on your server and launch your Meteor.js app.
Once you initiate the deployment, NodeChef will analyze your project and install the right Meteor.js version and all other binaries and packages required for your app to run.
The installation should typically take less than 5 minutes. However, if deploying from source using GIT, the installation can take up to 20 minutes depending on how large the Meteor.js app is. The installation is called the build phase on NodeChef. Once the installation completes, you can see your app by navigating to the Task manager → App actions → Browse.
Congrats. That should be it, see how easy it was. In less than 15 minutes, you have your Meteor.js app running on your EC2 Server. NodeChef simplifies the deployment of Meteor.js apps to AWS with our affordable and robust managed hosting offering.
Nothing as Easy as Deploying Meteor.js Apps on AWS
With NodeChef, you can have your Meteor.js apps up and running on managed cloud servers in just a few minutes.