Skip to main content

Production cloud deployments of fig infrastructure with docker

Project description

mfcloud
======

mfcloud alows to deploy your fig infrastructure to remote servers . Also it
provides all the services needed for hosting production apps.

Features:

- define your app config through Dockerfile and fig.yml
- easy deploy through git push
- pushing several versions of app (dev, staging, production ... etc)
- haproxy based balancer tcp
- easy switch balancer endpoint between app versions (ex swap prod and dev)
- persistent storage for containers
- easy copying persistence storage between containers (prod -> staging, etc)
- push and pull persistent volumes from your production server

Installation
-------------

Install docker: http://docs.docker.io/en/latest/installation/

Make sure you can run docker containers::

sudo docker run -i -t ubuntu echo -e "OK";

Install packages::

sudo apt-get install python-pip python-dev
sudo pip install mfcloud

Test that mfcloud is working::

$ mfcloud-server app-list

+-----+---------+-------+
| App | Version | State |
+-----+---------+-------+
+-----+---------+-------+

Create mfcloud user (you can pick any username)::

sudo useradd -s /bin/bash -d /home/mfcloud -m mfcloud
sudo su mfcloud
cd /home/mfcloud
mkdir ~/.ssh
vim ~/.authorized_keys # insert your ssh key and ssh key of your root user into this file
chmod -R go-rwx ~/.ssh

Test you can ssh into your server using mfcloud account::

ssh mfcloud@yourserver.com

Make sure your root user can also access your server::

sudo ssh mfcloud@yourserver.com

Add mfcloud user to docker group::

sudo usermod -a -G docker mfcloud

Check mfcloud can run docker now::

sudo su mfcloud
docker run -i -t ubuntu echo -e "\033[0;32mMfcloud can run Docker - OK\033[0m";
exit

Install haproxy::
sudo apt-get install haproxy
sudo echo "ENABLED=1" | sudo tee /etc/default/haproxy
sudo service haproxy start
sudo curl https://raw.github.com/pywizard/mfcloud/master/examples/haproxy.cfg.tpl | sudo tee /etc/haproxy/haproxy.cfg.tpl

Now install incron to reconfigure haproxy, when you deploy new apps::

sudo apt-get install incron
sudo echo "root" | sudo tee /etc/incron.allow

Edit incrontab file and insert lines generated by inotify-dump in incrontab file::

mfcloud-server inotify-dump

/home/mfcloud/apps-conf IN_MODIFY,IN_CREATE,IN_DELETE,IN_NO_LOOP /usr/local/bin/mfcloud-server balancer-dump /home/mfcloud/apps-conf
/etc/haproxy/haproxy.cfg.tpl IN_MODIFY,IN_CREATE,IN_DELETE,IN_NO_LOOP /usr/local/bin/mfcloud-server balancer-dump /home/mfcloud/apps-conf

$ sudo incrontab -e

And the last thing. Allow mfcloud to read-write any docker container volume:

mfcloud ALL= NOPASSWD:/usr/bin/rsync


Install git:

sudo apt-get install git


Deployement
-------------

Start by creating application that is working locally using fig.yml

Set working ssh account::

$ mfcloud use mfcloud@myserver.com

Create an application:

$ mfcloud remote app-create foo

Deploy code:

$ git push mfcloud@myserver.com:apps/foo master:prod

Check port number:

$ mfcloud remote app-list

Configure balancer:

$ mfcloud remote balancer set mydomain.com web:80@foo#prod

Push volume to deployment:

$ filcoud volume-push web/code@foo#master

Push volume from deployment:

$ filcoud volume-pull web/code@foo#master

Remote volume copy:

$ mfcloud remote volume-copy web/code@foo#master foo#v1

Your app is deployed!

Data migration
----------------

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mfcloud-0.2.2.tar.gz (2.1 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page