decidim/README.rst

57 lines
3.4 KiB
ReStructuredText
Raw Normal View History

2021-05-16 12:06:31 +02:00
Decidim
=======
Overview
--------
Decidim is a participatory democracy platform for cities and organizations. Decidim is written and runs on Ruby 2.7, where it is installed as Ruby Gem (i.e. not compiled from source). 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, hence the full compilation in ``Dockerfile``. Passenger sources contain ``passenger-install-nginx-module`` script which eases and semi-automates the compilation.
Custom fonts
------------
The image is distributed with custom version of *Source Sans Pro* font support for latin-ext characters included (i.e. diactitics). The original upstream version of the font omits these characters in order ta minimize the load times in web browsers.
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. The ``db/migrate`` directory is therefore stored on a persisten sotrage outside of the container to ensure that only the new database migration will be applied whenever the container is upgraded to a newer version of Decidim image.
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.
Rails environment
-----------------
Rails ``RAIL_ENV`` environment variable is set to ``production`` by default. This requires connection via HTTPS as there are redirects hardcoded in the Decidim application or its dependencies with enforce this behavior whenewer the ``RAILS_ENV`` is ``production``. The varaible can be changed to ``development`` in the docker-compose ``.env`` file, however the full development environment experience is not ensured by the current setup and some additional manual steps may be needed in order to use full potential of the development the environment.
The application offers a console accessible via
.. code-block:: bash
cd /srv/decidim-app
bin/rails console
The console loads the application environment and allows to work with Decidim via CLI. This is used by the docker entrypoint to ensure the superadmin credentials are always set according to the respective environment variables.
.. code-block:: ruby
Decidim::System::Admin.find_or_initialize_by(id: 1).update!(
email: ENV["DECIDIM_ADMIN_USER"],
password: ENV["DECIDIM_ADMIN_PASSWORD"],
password_confirmation: ENV["DECIDIM_ADMIN_PASSWORD"]
)