Decidim
=======

Overview
--------

Decidim is a participatory democracy platform for cities and organizations. Decidim is written and runs on Ruby 2.6, where it is installed as Ruby Gem. Incoming HTTP requests are handled via passenger nginx plugin.

Upstream URL: https://github.com/decidim/decidim

Passenger nginx plugin
----------------------

The passenger plugin work as application proxy between HTTP server and Ruby on Rails applications. Nginix doesn't have modules API like Apache does, so all nginx module must be present at compile time and only then they can be loaded and unloaded at runtime. Passenger plugin is not present in the standard Alpine nginx packages, therefore for passenger to work, a custom version of nginx including the passenger plugin needs to be compiled. Passenger sources contain ``passenger-install-nginx-module`` script which eases and semi-automates the compilation.

Database upgrades
-----------------

Decidim creates a series of database migration scripts under ``db/migrate`` directory. Unfortunately, these script are not created deterministically as their file names are always created with current build's timestamp. The same script using the same Decidim version therefore always ends up with different database migration scripts. Newly added scripts in a new version of Decidim are not sorted at the end, so it's impossible to determine which scripts need to applied from the filenames alone.

During manual upgrade, the workaround is to compare the directories between the old and the new image, stripping the timestamp and running only the scripts which don't exist in the old directory, however this is impossible to be done during automatic upgrade, as the old image is removed before the upgrade script is executed.

Additional site creation
------------------------

Decidim allows to create managed sites using the superadmin interface on ``https://<Decidim URL>/system/``. The sites require their own (sub)domains, therefore some additional considerations must be taken when setting up HTTP reverse proxies and TLS certificates.
