Docker is an open-source project to easily create lightweight, portable and self-sufficient containers from any application.

Fig.sh is a tool to use docker for makeing a fast, isolated development environments.

MEAN.JS MEAN means Mongodb, Express.js, Angular.js and Node.js. MEAN is a seed to setup a MEAN project quickly.

__more infomation your can see the offical site.*

This tutorial will tell you how to setup dockerizing MEAN project use less 20 mins(dependent on your network).

Prerequisites

You need have Docker, fig, If you are useing Mac your need boot2docker.

Ensure all the tools were installed:

$ docker version
$ fig –version

Get the MEAN.JS

Download the yo and install MEAN.JS with yo.

$ npm install -g yo generator-meanjs grunt
$ yo meanjs
$ grunt

Run the docker with fig

If you use Mac, you neet run the docker host first.

$ boot2docker up
$ $(boot2dockr shellinit)
$ boot2docker ip
// will display the ip address of docker host
// may be 192.168.53.103

change the DB connect URL from mongodb://localhost/mean-dev to mongodb://db/mean-dev. config file is config/env/development.js

Run $ fig up and open http://docker-host-ip:3000

That’s it. very simple.

But if you realy develop on this docker env

You mast don’t like to build the docker image every time. So you can mount the local development folder ./ to docker container.
It is very easy too. Just config the fig.yml under the web section

volumes:
- .:/data

Then when you change any thing in you local code folder, the running doceker container will change immediately.

But if you are useing Mac, it will be super slowly.

because, there is performance issue when VirtualBox shell a folder from mac to boot2docker. I finded out the key is node_modules folder. If I don’t mount the node_modules folder, the preformance is ok. So my solution is mount the other folder individual.

the fig.yml will like:

volumes:
- ./app:/data/app
- ./config:/data/config
- ./public:/data/public
- ./.jshintrc:/data/.jshintrc
- ./.csslintrc:/data/.csslintrc
- ./package.json:/data/package.json
- ./gruntfile.js:/data/gruntfile.js
- ./server.js:/data/server.js

That is all. :)