Giter Club home page Giter Club logo

loomio-deploy's Introduction

Deploy your own Loomio

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

If you just want a local install of Loomio for development, see Setting up a Loomio development environment.

It runs mutlitple services on a single host with docker and docker-compose. 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 18.04.

  • A domain name which you can create DNS records for.

  • An SMTP server for sending email.

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

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:

Install docker and docker-compose

These commands install docker and docker-compose, copy and paste.

snap install docker
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
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 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

Usage reporting

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 env file

DISABLE_USAGE_REPORTING=1

Setup SMTP

You need to bring your own SMTP server for Loomio to send emails.

If you already have and SMTP, that's great, put the settings into the env file.

For everyone else here are some options to consider:

Edit the env file and enter the right SMTP settings for your setup.

You might also need to add an SPF DNS 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 app 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.

Run crontab -e and apped the following line:

0 * * * *  /snap/bin/docker exec loomio-worker bundle exec rake loomio:hourly_tasks > ~/rake.log 2>&1

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

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 app 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

Confirm 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 exec -ti loomio-app rake db:migrate
docker-compose up -d

From time to time, or if you are running out of disk space (check /var/lib/docker):

docker system prune

To login to your running rails app console:

docker exec -ti loomio-app rails console

A PostgreSQL shell to inspect the database:

docker exec -ti loomio-db su - postgres -c 'psql loomio_production'

Backups

We have provided a simple backup script to create a tgz file with a database dump and all the user uploads and system config.

scripts/create_backup .

Your backup will be in loomio-deploy/backups/

You may wish to add a crontab entry like this. I'll leave it up to you to configure s3cmd and your aws bucket.

0 0 * * *  ~/loomio-deploy/scripts/create_backup ~/loomio-deploy > ~/backup.log 2>&1; s3cmd put ~/loomio-deploy/backups/* s3://somebucket/$(date +\%F)/ > ~/s3cmd.log 2>&1

loomio-deploy's People

Contributors

aym-frama avatar gdpelican avatar gregorykan avatar ldidry avatar modulistic avatar robguthrie avatar rohfle avatar tttp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.