Deploy your own Loomio
This repo contains a basic docker-compose configuration for running Loomio on your own server, with a domain name. If you just want a local install of Loomio with no domain, please follow the development handbook.
It assumes you want to run everything on a single host. It automatically issues an SSL certificate for you via the amazing letsencrypt.org.
What you'll need
Root access to a server, on a public IP address, running a default configuration of Ubuntu 14.04 x64.
A domain name which you can create DNS records for.
An SMTP server for sending email. More on that below.
What hostname will you be using for your Loomio instance? What is the IP address of your server?
For the purposes of this example, the hostname will be loomio.example.com and the IP address is 22.214.171.124
To allow people to access the site via your hostname you need an A record:
A loomio.example.com, 126.96.36.199
Loomio supports "Reply by email" and to enable this you need an MX record so mail servers know where to direct these emails.
MX loomio.example.com, loomio.example.com, priority 0
Configure the server
Login as root
To login to the server, open a terminal window and type:
ssh -A email@example.com
Install docker and docker-compose
These commands install docker and docker-compose, copy and paste.
wget -qO- https://get.docker.com/ | sh wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` chmod +x /usr/local/bin/docker-compose
Clone the loomio-deploy git repository
This is the place where all the configuration for your Loomio services will live. In this step you make a copy of this repo, so that you can modify the settings to work for your particular setup.
As root on your server, clone this repo:
git clone https://github.com/loomio/loomio-deploy.git cd loomio-deploy
The commands below assume your working directory is this repo, on your server.
Setup a swapfile (optional)
There are some simple scripts within this repo to help you configure your server.
This script will create and mount a 4GB swapfile. If you have less than 2GB RAM on your server then this step is required.
Create your ENV files
This script creates
env files configured for you. It also creates directories on the host to hold user data.
When you run this, remember to change
loomio.example.com to your hostname, and give your contact email address, so you can recover your SSL keys later if required.
./scripts/create_env loomio.example.com firstname.lastname@example.org
Now have a look inside the files:
By default your Loomio instance will report back to www.loomio.org with the number of discussions, comments, polls, stances, users and visits that your site has had.
Once per day it will send those numbers and your hostname to us, so that we are able to measure Loomio usage around the world, so that we can tell what impact our work is having.
If you wish to disable this reporting function, add the following line to your
Loomio is technically broken if it cannot send email. In this step you need to edit your
env file and configure the SMTP settings to get outbound email working.
So, you'll need an SMTP server. If you already have one, that's great, you know what to do. For everyone else here are some options to consider:
For setups that will send less than 99 emails a day use smtp.google.com for free.
Soon we'll publish a guide to setting up your own private and secure SMTP server.
env file and enter the right SMTP settings for your setup.
You might need to add an SPF record to indicate that the SMTP can send mail for your domain.
Initialize the database
This command initializes a new database for your Loomio instance to use.
docker-compose run loomio rake db:setup
Doing this tells the server what regular tasks it needs to run. These tasks include:
- Noticing which proposals are closing in 24 hours and notifying users.
- Closing proposals and notifying users they have closed.
- Sending "Yesterday on Loomio", a digest of activity users have not already read. This is sent to users at 6am in their local timezone.
The following command appends some lines of text onto the system crontab file.
cat crontab >> /etc/crontab
Sign in via third party
If you want to allow users to sign in via Google, Facebook, Twitter or Github, then you'll need to add APP_KEY and APP_SECRET env lines for each provider you wish to support.
You'll find env records for these providers commented out in your env file by default.
Starting the services
This command starts the database, application, reply-by-email, and live-update services all at once.
docker-compose up -d
You'll want to see the logs as it all starts, run the following command:
You might like to keep an additional console open by your side to watch for potential errors or warnings:
docker-compose logs -f
Try it out
visit your hostname in your browser.
Once you have signed in (and confirmed your email), grant yourself admin rights
docker-compose run loomio rails c User.last.update(is_admin: true)
you can now access the admin interface at https://loomio.example.com/admin
If something goes wrong
env settings are correct.
After you change your
env files you need to restart the system:
docker-compose down docker-compose up -d
To update Loomio to the latest image you'll need to stop, rm, pull, apply potential changes to the database schema, and run again.
docker-compose down docker-compose pull docker-compose run loomio rake db:migrate docker-compose up -d
From time to time, or if you are running out of disk space (check
docker rmi $(docker images -f "dangling=true" -q)
To login to your running rails app console:
docker-compose run loomio rails console
A PostgreSQL shell to inspect the database:
docker exec -ti loomiodeploy_db_1 su - postgres -c 'psql loomio_production'
Building a backup policy
Most of the environment we have set up so far can be considered disposable, as it can be rebuilt from scratch in a few minutes.
Things you want to consider when designing a proper backup policy:
And a database dump:
docker exec -ti loomiodeploy_db_1 su - postgres -c 'pg_dump loomio_production' \ | xz \ > $(date +%Y-%m-%d_%H:%M).pg_dump.xz
Be sure you exclude
loomio-deploy/pgdata — all you need from the database is in the dump.
Connecting the Slack app with your instance
Click here for more info on how to connect the loomio slack bot to your instance.
Need some help? Visit the Installing Loomio group.