~hacktivista/setup-decidim

Creates a fully working Decidim installation for development or production
Better support asset sharing between Nginx and Decidim containers
Fix: Don't break certbot-nginx by leaving a temporarily broken nginx config
Fix: support GIT_CLONE_REPO on LXD' Decidim

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~hacktivista/setup-decidim
read/write
git@git.sr.ht:~hacktivista/setup-decidim

You can also use your local clone with git send-email.

#Decidim container installer

Install Decidim on LXD or any other container.

In case of LXD the host distribution is irrelevant, in any other case you will need Alpine Linux.

#Requirements

  • pwgen
  • curl

#Usage instructions

  1. Clone the repo.
  2. Copy config-dist.sh to config.sh or config.anything.sh and change whatever you need to change.
  3. Optionally copy a Decidim fork on a src directory.* **
  4. Run setup.sh (as root in native mode). Reads config.sh by default, if you prefer to use other file provide it as parameter.

* If you place an empty directory instead, it will populate the directory with a fresh or existing copy of Decidim given that you've set one on $GIT_CLONE_REPO. Be aware that Decidim hardcodes database name on config/database.yml to ${DECIDIM_INSTANCE}_${ENVIRONMENT}.

** For LXD you will need to enable subuid and subgid mappings, active for the owner of src/. Here a quick snippet for activation:

printf "lxd:$(id -u):1\nroot:$(id -u):1\n" | sudo tee -a /etc/subuid
printf "lxd:$(id -g):1\nroot:$(id -g):1\n" | sudo tee -a /etc/subgid
# restart lxd daemon now

#Common tasks after installation

#Expose the LXD Nginx container to the world using nftables

HOST_IP=<set>
NGINX_IP=<set>
nft add table nat
nft 'add chain nat postrouting { type nat hook postrouting priority 100 ; }'
nft 'add chain nat prerouting { type nat hook prerouting priority -100 ; }'
nft "add rule nat prerouting ip daddr $HOST_IP tcp dport 80 dnat $NGINX_IP:80"
nft "add rule nat prerouting ip daddr $HOST_IP tcp dport 443 dnat $NGINX_IP:443"
nft list ruleset | tee /etc/nftables.*

#Access LXD Decidim container with env vars set

lxc exec <container_name> -- su - <container_name> -c ash

#Add modules

You can install some gems by uncommenting or adding Decidim gems

$EDITOR Gemfile
bundle install

# then depending on what you've uncommented
# bin/rails decidim_consultations:install:migrations
# bin/rails decidim_conferences:install:migrations
# bin/rails decidim_initiatives:install:migrations
# bin/rails decidim_templates:install:migrations

bundle exec rails db:migrate

#Seed database with test data

bundle exec rails db:seed

#FAQ

#Will it ever support other distributions?

Probably! I accept sane non-breaking contributions which deal with other operating systems.

#What about Docker?

It would work, but data would be missing after reboots given its stateless nature. I'm willing to accept contributions of Docker Compose setups or scripts that use Docker, given that these deal with persistent storage and use setup.sh or decidim.sh.

#License

GPLv3 only.