This short guide helps you setup a consistent Docker based development environment for Manshar. It makes use of fig to instantiate a set of containers to run a development instance of Manshar.
You will need a linux host to act as the docker host. A docker host will run the Manshar containers that are necessary to run the webapp services. If you are already using a linux machine for development, you may use the same machine as the containers host. Otherwise, you will need access to a linux machine for that purpose. The easiet way to achieve the latter is to spin a linux VM on your development machine. We recommend using boot2docker, which is a preconfigured virtualbox linux VM that has docker pre-installed on it. In addition, boot2docker provides a simple CLI tool to manage the docker host VM.
Make sure to install docker on your development machine. You can find the installation instructions for your distribution here.
Install boot2docker as per the instructions that can be found here. After installing boot2docker, make sure to initialize the boot2docker VM by running:
$ boot2docker init
Install Fig as described in the instructions here
If you are using boot2docker, make sure to run the following two commands first:
$ boot2docker up
$ $(boot2docker shellinit)
The first of these commands will make sure that the boot2docker VM is up and running. The second command will initialize some environment variables that are used by the 'docker' CLI tool so that it knows which docker server it should talk to (the one running on the boot2docker VM).
Note that these two commands should always be run when restarting the boot2docker VM.
- Edit the fig.yml and replace the 'dockerhost' strings with the IP address or hostname of the docker host. In the case you are using boot2docker, you can figure out the VM IP address by running:
$ boot2docker ip
- Initialize the database container by running the following command:
$ fig run backend ./init_db.sh
Note that running these commands might take a significant amount of time, depending on your Internet connection. The reason being that these commands will pull the Manshar's development environment docker containers from docker hub. Once these commands finish runing, you're development environment should be ready.
Running the Manshar servers is as simple as running:
$ fig up
The reverse of up
is down
:
$ fig down
This depends on which container you want to install extra packages to. For example, if you need to install packages to the 'web' container, you can run
$ fig run web npm install <whatever-package>
For More Information on How to Deal with Docker Containers and Fig, checkout the docker and fig documentation.
If you get this message when running any docker or fig commands, restart the boot2docker VM by running:
$ boot2docker down
$ boot2docker up
And then run your command again.