Public | Automated Build

Last pushed: 3 months ago
Short Description
MeteorD - Docker Runtime for Meteor Apps for Production Deployments
Full Description

This project is no longer maintained

See jshimko/meteor-launchpad for a stable and maintained Docker base image for Meteor apps.

MeteorD - Docker Runtime for Meteor Apps

There are two main ways you can use Docker with Meteor apps. They are:

  1. Build a Docker image for your app
  2. Running a Meteor bundle with Docker

MeteorD supports these two ways. Let's see how to use MeteorD

1. Build a Docker image for your app

With this method, your app will be converted into a Docker image. Then you can simply run that image.

For that, you can use meteorhacks/meteord:onbuild as your base image. Magically, that's only thing you have to do. Here's how to do it:

Add following Dockerfile into the root of your app:

FROM meteorhacks/meteord:onbuild

Then you can build the docker image with:

docker build -t yourname/app .

Then you can run your meteor image with

docker run -d \
    -e ROOT_URL=http://yourapp.com \
    -e MONGO_URL=mongodb://url \
    -e MONGO_OPLOG_URL=mongodb://oplog_url \
    -p 8080:80 \
    yourname/app

Then you can access your app from the port 8080 of the host system.

Stop downloading Meteor each and every time (mostly in development)

So, with the above method, MeteorD will download and install Meteor each and every time. That's bad especially in development. So, we've a solution for that. Simply use meteorhacks/meteord:devbuild as your base image.

WARNING: Don't use meteorhacks/meteord:devbuild for your final build. If you used it, your image will carry the Meteor distribution as well. As a result of that, you'll end up with an image with ~700 MB.

2. Running a Meteor bundle with Docker

For this you can directly use the MeteorD to run your meteor bundle. MeteorD can accept your bundle either from a local mount or from the web. Let's see:

2.1 From a Local Mount

docker run -d \
    -e ROOT_URL=http://yourapp.com \
    -e MONGO_URL=mongodb://url \
    -e MONGO_OPLOG_URL=mongodb://oplog_url \
    -v /mybundle_dir:/bundle \
    -p 8080:80 \
    meteorhacks/meteord:base

With this method, MeteorD looks for the tarball version of the meteor bundle. So, you should build the meteor bundle for os.linux.x86_64 and put it inside the /bundle volume. This is how you can build a meteor bundle.

meteor build --architecture=os.linux.x86_64 ./

2.1 From the Web

You can also simply give URL of the tarball with BUNDLE_URL environment variable. Then MeteorD will fetch the bundle and run it. This is how to do it:

docker run -d \
    -e ROOT_URL=http://yourapp.com \
    -e MONGO_URL=mongodb://url \
    -e MONGO_OPLOG_URL=mongodb://oplog_url \
    -e BUNDLE_URL=http://mybundle_url_at_s3.tar.gz \
    -p 8080:80 \
    meteorhacks/meteord:base

2.2 With Docker Compose

docker-compose.yml

dashboard:
  image: yourrepo/yourapp
  ports:
   - "80:80"
  links:
   - mongo
  environment:
   - MONGO_URL=mongodb://mongo/yourapp
   - ROOT_URL=http://yourapp.com
   - MAIL_URL=smtp://some.mailserver.com:25

mongo:
  image: mongo:latest

When using Docker Compose to start a Meteor container with a Mongo container as well, we need to wait for the database to start up before we try to start the Meteor app, else the container will fail to start.

This sample docker-compose.yml file starts up a container that has used meteorhacks/meterod as its base and a mongo container. It also passes along several variables to Meteor needed to start up, specifies the port number the container will listen on, and waits 30 seconds for the mongodb container to start up before starting up the Meteor container.

Rebuilding Binary Modules

Sometimes, you need to rebuild binary npm modules. If so, expose REBUILD_NPM_MODULES environment variable. It will take couple of seconds to complete the rebuilding process.

docker run -d \
    -e ROOT_URL=http://yourapp.com \
    -e MONGO_URL=mongodb://url \
    -e MONGO_OPLOG_URL=mongodb://oplog_url \
    -e BUNDLE_URL=http://mybundle_url_at_s3.tar.gz \
    -e REBUILD_NPM_MODULES=1 \
    -p 8080:80 \
    meteorhacks/meteord:binbuild

Known Issues

Spiderable Not Working (But, have a fix)

There are some issues when running spiderable inside a Docker container. For that, check this issue: https://github.com/meteor/meteor/issues/2429

Fortunately, there is a fix. Simply use ongoworks:spiderable instead the official package.

Container won't start on Joyent's Triton infrastructure

There's currently (2015-07-18) an issue relating to how the command or entry point is parsed, so containers won't boot using the 'docker run' commands as above.

Instead, Joyent support has suggested the following workaround until their fix can be rolled out.

docker run -d \
    -e ROOT_URL=http://yourapp.com \
    -e MONGO_URL=mongodb://url \
    -e MONGO_OPLOG_URL=mongodb://oplog_url \
    -p 80:80 \
    --entrypoint=bash \
    yourname/app \
    /opt/meteord/run_app.sh
Docker Pull Command
Owner
meteorhacks
Source Repository

Comments (7)
garyascuy
10 months ago

JIC: If you are searching low size for meteor, https://hub.docker.com/r/meteorjs/example/ this is an meteor app (DiscoverMeteor/Microscope) in just 22MB, smallest that ever and works with meteor 1.4.2.3, they have a command line tool to reduce the size. I want to create a community around this project all are invited !!! there is many things todo like meteor_onbuild image ... improve tools ...

stonefury
10 months ago

Where can I specify the meteor version? Or is that part of the meteor app?

krok
a year ago

Just tried with METEOR@1.3.4.4. The docker build freezes after meteor got installed.
Seems to be an Issue. Hmm... Very frustrating.

parallel
2 years ago

It cost much memorys

arunoda
3 years ago

@freiit

Oh yes. I'll update the README.

freiit
3 years ago

I'm using the official mongodb image as a container

docker run -d --name mongodb -v /my_mongodata:/data/db mongo:2.6

So you can set the MONGO_URL to "MONGO_URL=mongodb://mongodb:27017/my_db" and have the two containers work together.

freiit
3 years ago

The second last line should imho read: "-p 8080:80" instead of "-p 80:3000".