[Docker Setup] Loomio: A non-hierarchical group decision-making platform

in #beyondbitcoin8 years ago (edited)

loomio-new-way-1f6afc1168e13badfd134e793b92f5eb45eae569234fac1f0db47eaba8592ee9fa881.png

So last time I described a docker platform in some amount of detail, both manual and automated. Today I’m going to talk about how to use a platform like that to run exposed web applications from your home computer, instead of from a cluster. To use the platform I describe here, you’re going to require 1 (one) public IPv4 address, but it doesn’t need to be attached to your PC, or even your cable modem, you just need one of these addresses in the cloud.... or if you live in a civilized country, you've already got one at your cable modem. But I'm assuming a primarily American audience, and the ISP market isn't too competitive there, so people are stuck with DHCP addresses and other forms of government enabled ISP customer-abuse and government supported speech-limiting.

From the cloud IP address, we will attach your computer to the same virtual network (weave net by weave.works) and then just as before we will use Caddy on the cloud machine to direct web traffic from the public IP address to the private one that the container on your computer that is now running Loomio. A really great place to get your $3 cloud address is scaleway.com (and this is not a paid endorsement, but I should probably ask them how to get paid ;) )

So, here goes:

Loomio is a Ruby application, something we’re seeing a lot less of these days and so a bit of a challenge for me…. But they’ve mode to Docker, so setting this up should be not very challening at all.

Step zero: Put docker on your PC (Assuming it is a linux machine-- if it isn't well then god bless ya, and you should follow the directions at docker.com-- docker has great cross platform support owing to its use of golang.

Wget get.docker.com
Sh index.html

This part direct from Loomio’s Github repo, they’ve done a more-than-adequate job and reproducing it would be senseless:


Deploy your own Loomio

This repo contains a basic docker-compose configuration for running Loomio on your own server.

It assumes you want to run everything on a single host. It automatically issues an SSL certificate for you via the amazingletsencrypt.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.

Network configuration

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 123.123.123.123

DNS Records

To allow people to access the site via your hostname you need an A record:

A loomio.example.com, 123.123.123.123

You also need to setup a CNAME record for the live update service

CNAME faye.loomio.example.com, loomio.example.com

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 protected]

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.6.2/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.

./scripts/create_swapfile

Create your ENV files

This script creates env and faye_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 [email protected]

Now have a look inside the files:

cat env

and

cat faye_env

Setup SMTP

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.

  • Look at the (sometimes free) services offered by SendGrid, SparkPost, Mailgun, Mailjet.

  • Soon we'll publish a guide to setting up your own private and secure SMTP server.

Edit the 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.

nano env

Initialize the database

This command initializes a new database for your Loomio instance to use.

docker-compose run loomio rake db:setup

Install crontab

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

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:

docker-compose logs

Try it out

visit your hostname in your browser. something like https://loomio.example.com. You should see a login screen, but instead sign up at https://loomio.example.com/users/sign_up

Test the functionality

Test that email is working by visiting https://loomio.example.com/users/password/new and get a password reset link sent to you.

Test that live update works with two tabs on the same discussion, write a comment in one, and it should appear in the other. Test that you can upload files into a thread. Test that you can reply by email. test that proposal closing soon works.

If something goes wrong

confirm env settings are correct.

After you change your env file you need to restart the system: run docker-compose down then docker-compose up -d

To update Loomio to the latest image you'll need to stop, rm, pull, and run again.

docker-compose down
docker-compose pull
docker-compose up -d

To login to your running rails app console:

docker exec loomiodeploy_worker_1 bundle exec rails console

Need some help? Visit the Installing Loomio group.


And Back to stuff that I wrote:

Getting "out"

Now, you’ve got loomio on your computer, but suppose you’d like to share your loomio with the internet at large: here’s where weave comes into play.

Install weave on your PC like this:

sudo curl -L git.io/weave -o /usr/local/bin/weave
sudo chmod +x /usr/local/bin/weave
weave launch yourpublicipaddresinthecloudmentionedearlier

Now you have your home PC and your cloud machine (only a minimal spec is needed, really-- just about any VM should do quite well). Connected on a virtual network.

Make sure that you run

"Weave expose"

On both machines and then you need to run

Docker ps (note the container IDs)

Weave attach containerid1, 2, 3

Now that that is done, try visiting loomio in your computer’s browser at the IP address that comes up after weave expose and the port used by Loomio. If that works, great you’ve passed the first test of the system. Now, the final bit will be gettting this container served at a proper domain name. Lucky for us this has gotten much easier lately, enter

Caddy Web Server

Caddyserver.io

**Caddy is a web server with automated HTTPs certificates for that green-lock experience from day one. **

Go ahead, open up your Caddyfile and configure a Caddy proxy:

It should look something like this:

www.chicken.com chicken.com{
gzip
proxy www.chicken.com 10.32.0.1 
}

Send traffic from the URL you want to redirect to your caddy server’s docker container IP address, and you’ll be all set!

Just to be clear, you want to configure the "proxy" line in the above code box.


For good measure, follow me, @faddat
and even better, join myself and @officialfuzzy on the BeyondBitcoin Show on Friday at 9AM CST!
....finally, if you liked the post, help it gain some exposure and reblog the hell out of it :D!

Sort:  

Excellent! I'm totally going to look into setting this up! :D

Coin Marketplace

STEEM 0.27
TRX 0.11
JST 0.031
BTC 71329.64
ETH 3801.49
USDT 1.00
SBD 3.50