[Dockerize] Deploy Meteor App using Docker with $5/mo (The Force Awakens)

Gary Ascuy
Apr 30, 2017 · 4 min read


I’m a meteor developer, I’ve worked long time with this framework, ~2 years more or less. And when I’ve tried to deploy my application, I had many problems like where can I deploy? what is the best option? what things I need to do to have ready in production? I did a lot of research about topic and here I want to share with you the experience related with the process of deploy and all the things that I’ve learned.

There are many alternatives to deploy a Meteor application. and Meteor guys in their site recommend Galaxy, but if someone ask me define Galaxy in one word, I would say “Expensive”. With $28.8 you can have essential container with compact plan, It includes 500MB in Ram and 0.5 ECU (ECU: EC2 Compute Unit) without tech support. with same price you can have more than 5 machines with doble ECU in amazon or digital ocean. So what are you paying with those extra $23.8? The knowledge about the deployment process. Then Let’s learn it to reduce our costs :-) !!!


- OS: MacOS or Linux
- Git (* there is a workaround to avoid this)
- Meteor
- Docker 17.03.1-ce


In this story we will cover the process to create a Docker image from the source code of a Meteor App. In next stories I will explain about the process to deploy Docker image into Digital Ocean also considering performance things. I am assuming that you know little bit about git, docker, and meteor.

Ok, not more introductions, let’s do it

Meteor is an open source platform for web, mobile, and desktop. and It includes command line interface to create, run and build apps, if you don’t know anything about Meteor, I recommend you discover meteor site here.

As a first step we need the source code of meteor application, for this example we will use todos, I did small changes and publish the code here, you need to download the code, for that you can use “git clone” (workaround: download as zip file from git hub).

To test if all is working fine you can run in development mode, for this try to execute these commands: meteor npm install && meteor. After that open in the browser http://localhost:3000/. The todos example app should be run in that route.

Now we need to create a Meteor server side build for linux architecture, for this we can run the following command:

This command needs to be executed in the meteor app folder and it creates a file called ../build/todos.tar.gz, this file contains all minified code, assets, etc. of the Meteor App. and we will use this file to create a Docker image. the recommended method to create images in Docker is using a Dockerfile. We need to create a file called Dockerfile in build folder when we have the meteor build, the new file should have this content:

Reviewing a little bit about this file, first we are using as base image “node:4.8.2-alpine” that mainly because Meteor requires NodeJS 4.8.2 and alpine is light version of linux. I use that because Docker guys recommend it. It is more secure don’t have useless dependencies in the deploy.

A good thing of ADD[line:12] command when we pass compressed file, it unzipped the file and as result we will have out build into /root/app/bundle/ folder.

And finally RUN[line:13,14,15] in this step we are installing the dependencies in the OS. And immediately we are running “npm install — unsafe-perm”, it download/install/compile all node modules that are needed for our app. After it we need to uninstall the dependencies of OS to reduce the image size, since we don’t need them anymore. Ok we now have all that we need to create the image, just execute the following commands:

The first one command, docker build need to be run in build folder and It executes the Dockerfile and creates a image, you can review the result with “docker images” it should be list garyascuy/todos (garyascuy is my user name in docker hub. if you want to publish your images you will need an account and replace my name for your account).

the last one publish the image as public in docker hub. and we have our image ready to deploy. if you follow all steps in this story … Congratulations you are ready to deploy in the Cloud !!!

if you have some comment, observation, something … about this story, just let me know in order to improve and fix. thanks in advance for the feedback.

Gary Ascuy <gary.ascuy@gmail.com>

Gary Ascuy

Written by

Full-Stack Developer + Operations