Antragsgrün
Antragsgrün is an easy-to-use online tool for NGOs, political parties, and social initiatives to collaboratively discuss resolutions, party platforms, and amendments. It helps to manage candidacies and supports meetings by providing online votings, speaking lists, and many more features.
A number of organisations are using the tool successfully such as the European and German Green Party, Volt Europe, the European Youth Forum and the National Council of German Women's Organizations. It can be easily adapted to a variety of scenarios.
Core functions:
- Submit motions, proposals and discussion papers online
- Clear amendming process for users and administrators
- Discuss motions
- Draft resolutions
- Votings
- Speaking lists
- Multi-language motions and amendments
- Diverse export options
- Great flexibility - it adapts to a lot of different use cases
- Technically mature, data privacy-friendly
- Accessible, following WCAG AA
Using the hosted version / testing it
- German: https://antragsgruen.de
- English: https://motion.tools, https://discuss.green
- French, Dutch, Catalan, Spanish and Swedish: https://discuss.green
Installation
Using the pre-bundled package
Requirements:
- A MySQL/MariaDB-database
- PHP >= 8.2. Recommended: 8.4+. Required packages for Debian / Ubuntu Linux:
# Using PHP8-packages from [deb.sury.org](https://deb.sury.org/):
apt-get install php8.4 php8.4-cli php8.4-fpm php8.4-intl php8.4-gd php8.4-mysql \
php8.4-opcache php8.4-curl php8.4-xml php8.4-mbstring php8.4-zip php8.4-iconv
- Apache or nginx. Example files are provided here:
Installation:
- Download the latest ZIP/BZIP2-package of Antragsgrün.
- Extract the contents into your web folder
- Access the "antragsgruen/"-folder of your web server, e.g. if you have extracted the package into the web root of your host named www.example.org/, then access www.example.org/antragsgruen/
- Use the web-based installer to configure the database and further settings
From the sources
Install the sources and dependencies from the repository:
git clone https://github.com/CatoTH/antragsgruen.git
cd antragsgruen
curl -sS https://getcomposer.org/installer | php
./composer.phar install --prefer-dist
pnpm install
pnpm run build
rm -Rf local/cdn/dev && docs/create-static-resources.php dev
If pnpm is not installed, you can either install it by brew install pnpm (macOS), npm install -g pnpm (NPM-based) or use the pnpm-helper image (Docker), as described in Developing with Docker Compose.
If you want to use the web-based installer (recommended):
touch config/INSTALLING
If you don't want to use the web-based installer:
cp config/config.template.json config/config.json
vi config/config.json # you're on your own now :-)
Set the permissions (example for Debian Linux):
sudo chown -R www-data:www-data web/assets
sudo chown -R www-data:www-data runtime
sudo chown -R www-data:www-data config #Can be skipped if you don't use the Installer
Using the Docker Image
A Docker Image is provided on:
It comes in two flavors:
full(default) contains everything, including better PDF generation (Weasyprint) and tools for image processing (for uploading applications).minimalcontains everything, but without these extra tools. The image is therefore significantly smaller, but some functionality will be missing.
Tagging conventions are:
latestpoints to the most recent *Release, infullflavor.latest-minimalpoints to the most recent Release, inminimalflavor.- Each release gets two version-specific tags. 4.17.0, for example, receives
4.17.0-fulland4.17.0-minimal. - Git-Tags can get their own Docker images, using the same tag as on git (minus leading
v). Git-Tags do not set thelatest/latest-minimaltags. This is used to provide interim releases on request for customers.
A sample on how to use it can be seen in the bundles docker-compose.yml.
Usage for first-time installation:
cp .env.example .env
echo "\n# Application Secret\nRANDOM_SEED=$(openssl rand -base64 32)" >> .env # One time initialization of a local secret key
docker compose start
docker exec antragsgruen-web-1 /root/enable-installer.sh # To enable the install mode
After this, http://localhost:12380/ should show the installer. The database connection is pre-configured in to use the MariaDB in the Docker-Compose.yml, so no need to change it.
To update to a newer version of Antragsgrün, remove the image and pull the latest tag:
docker compose down
docker image rm tobiashoessl/antragsgruen:latest
docker compose up
docker exec -it antragsgruen-web-1 /var/www/html/yii migrate # To perform potential database updates.
Caution: Docker and Environment Variables
While it is possible to configure Docker-based Antragsgrün through environment variables, when using the Web-based installer as described here, some configuration will still be stored in a local configuration file (config/config.json).
Most crucially, a random key is created, saved in this file and used to hash security-related information like passwords. It is therefore mandatory to not store this file in the container, but a volume! The default docker-compose.yml achieves this by using the whole config directory as volume. Alternatively, this key can be set up through environment variables manually.
Alternative Docker Image
Jugendpresse Deutschland e.V. developed a container image, which is now maintained as an open source / collaborative project at github.com/devops-ansible/docker-antragsgruen.
The repository is maintained to run its workflows once a week to build the devopsansiblede/antragsgruen image.
The latest contents of the master branch will result in a dev_YYYYMMDD-HHII image-tag with the build date and time mentioned as well as the development image-tag.
The actual (new) releases by git tags in the official Motiontool repository are built into images as well. They result in the tags latest being the latest (highest) released version, and semantic version partials mapping the corresponding versions, so vA.B.C is the current patch level version, vA.B is the latest released patch of the minor version, and vA is the latest released patch of the major version.
You can find the container images published on DockerHub.
Updating
Using the web-based updater
Site administrators of an installation will see an Update-Box on the right side of the administration page of a consultation. The box indicates if an update is available. If so, you can switch the whole installation into Update mode. While the update mode is active, the whole site will not be available to other users.
Once the update mode is active, the /update.php script will be available to the site administrator. Here, the update can be performed in two to three steps:
- Download the update file
- Install the new files
- Apply database updates (this is usually only necessary when upgrading to a new minor version, e.g. from 3.9 to 3.10.)
Before using the updater, it is generally a good idea to back up all files and especially the database.
If you encounter any problem using the web-based updater, please consult the Update Troubleshooting FAQ.
Using the pre-bundled package
- Download the latest package of Antragsgrün (see "Installation")
- Extract the files to your web folder, overwriting all existing files. The configuration (in config/config.json) will not be affected by this.
- Remove the
config/INSTALLINGfile - If you have shell access to your server: execute
./yii migrateon the command line to apply database changes - If you don't have shell access to your server: please refer to UPGRADING.md on how to upgrade your database
Installing from the git repository
A bash script that performs git pull for the current branch, installs dependencies, compiles assets and performs database migrations can be found here:
PDF-Rendering
Generating PDFs is performed by the PHP-Library TCPDF by default. In some cases, nicer and easier to customize PDFs can be generated though by using a separate command line tool to generate them. They need to be set up and configured by hand on the server though.
Weasyprint-based PDF-rendering
As an optional alternative way to create PDFs that are slightly more aesthetically pleasing, Antragsgrün supports using Weasyprint as a rendering backend. This needs to be installed on the command line. Also, the qpdf command line tool is necessary, to improve compatibility of the generated PDF files.
When using the docker image, the full image variant comes preconfigured with Weasyprint. When using the regular way (downloading the source code or zip/bz2-bundle), it needs to be installed on the system by hand:
Variant 1, for a Linux distribution with a reasonably recent version of Weasyprint (60+):
apt-get install weasyprint qpdf
Variant 2, installation using pip (requires Python 3 including VirtualEnv support):
python3 -m venv venv
source venv/bin/activate
pip install weasyprint
weasyprint --info
(Refer to: https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#linux)
Add the following settings to your config.json (and adapt them to your needs):
{
"weasyprintPath": "/usr/bin/weasyprint",
"qpdfPath": "/usr/bin/qpdf"
}
Deployment and Performance Optimization
Setting Super-Admins
Super-Admins are administrators with some additional set of privileges not available to regular site administrators:
- They can modify the user data of registered users (setting the name, organization and a new password).
- They can download and install new versions of Antragsgrün and set the whole site into maintenance mode.
- On Multisite installations, they are automatically set as administrator for every site.
The list of super-admins cannot (on purpose) be changed using the Web-UI,
but has to be manually changed in the config/config.json by adding and removing the user IDs in the adminUserIds array.
Securing Accounts
Antragsgrün comes with built-in support for protecting user accounts from brute-force accounts. By default:
- A CAPTCHA needs to be solved after three unsuccessful login attempts for every further login attempt.
- Users can opt in to protect their accounts using a second factor authentication app (TOTP).
Configuring the CAPTCHA
The default behavior of the CAPTCHA can be modified in the config.json:
- The
modeindicates when a CAPTCHA is shown. The defaultthrottlerequires it after three unsuccessful attempts, balancing security with trying not to bother users too much.alwaysalways requires entering a CAPTCHA,neverdisables it entirely. difficultydefaults tonormal, which should be solvable by most users. To make it easier (no distortion of image), set it toeasy.ignoredIpsis a list of IP addresses that will never receive a CAPTCHA. This is often necessary on conventions where all delegates are sharing one WiFi IP address and unsuccessful login attempts of one delegate would otherwise trigger CAPTCHA-behavior for all others.
{
"captcha": {
"mode": "always", // Options: "never", "throttle", "always"
"ignoredIps": [
"127.0.0.1",
"::1"
],
"difficulty": "easy" // Options: "easy", "normal"
}
}
Configuring / Enforcing 2FA
By default, users have the option to secure their account with a TOTP-based second factor (supported by many apps like Authy, Google Authenticator, FreeOTP or password managers). Super-Admins can change this behavior on an per-user-basis:
- Setting a second factor can be enforced.
- Setting a second factor can be disabled (changing passwords can be prevented too, e.g. for accounts meant to be shared).
- A second factor can be removed, e.g. if the user lost access to their 2FA-app.
Integration Single-Sign-On-Providers
The user administration of Antragsgrün can be connected to a SSO provider, for example using SAML. However, this is not part of the core distribution, as the requirements are typically too organization-specific.
ImageMagick
To resize uploaded images in applications on the server side, and to enable uploading PDFs as images, ImageMagick needs to be installed as command line tool:
- Install the packages. On Debian-based systems,
apt-get install imagemagickshould do the trick. - Make sure PDF operations are allowed. On Debian-based systems, check the file
/etc/ImageMagick-6/policy.xmland comment out<policy domain="coder" rights="none" pattern="PDF" />if necessary. - Set the path to the binary in
imageMagickPathinconfig/config.json.
Multisite-Mode
There are two ways to deploy multiple sites using one codebase, each site allowing multiple consultations. However, both of them are non-trivial.
Using a completely separate configuration and database
If you want to use two completely different databases, or a different set of active plugins, you can create a separate config.json for each installation and name them like config.db1.json, config.db2.json, etc. Which one is used on a request depends on the environment variable ANTRAGSGRUEN_CONFIGthat is provided to the PHP process. For example, to use config.db1.json on the hostname db1.antragsgruen.local on Apache, you can use the following line in the Apache configuration:
SetEnvIf Host "db1.antragsgruen.local" ANTRAGSGRUEN_CONFIG=/var/www/antragsgruen/config/config.db1.json
For command line commands, you can set this variable like this:
ANTRAGSGRUEN_CONFIG=/var/www/antragsgruen/config/config.db1.json ./yii database/migrate
Using the same database, plugin configuration and a site manager
Antragsgruen.de uses a site manager module on the home page that allows users to create their own sites using a web form. This is done using the multisideMode and a plugin for the site manager. Relevant entries in the config.json for this are:
{
"multisiteMode": true,
"siteSubdomain": null,
"domainPlain": "https://antragsgruen.de/",
"domainSubdomain": "https://<subdomain:[\\w_-]+>.antragsgruen.de/",
"plugins": ["antragsgruen_sites"]
}
Instead of "antragsgruen_sites", a custom plugin managing the authentication and authorization process and providing the custom home page is necessary for this use case. The default manager antragsgruen_sites can be used as an example for this
Deployment using Environment Variables (Docker, Kubernetes)
Instead of configuring Antragsgrün via the traditional config.json file, it is also possible to provide most of the supported settings using environment variables.
Please refer to the Environment Variables Documentation for more information.
Integrating a CDN for Static Assets
Integrating a CDN consists of two steps (when using the source version). First, configure it in your config.json (or the RESOURCE_BASE environment variable):
{
"resourceBase": "https://cdn.motion.tools/{CDN_TAG}/"
}
CDN_TAG identifies a subdirectory on your CDN, which, if provided, needs to match what will be set in the next step.
Then, to create an uploadable bundle and a local manifest about dependencies between JS Modules:
docs/create-static-resources.php choose-a-cdn-subdirectory
rsync --progress -a -v local/cdn/ your-subdirectory
Hint: If a CDN / A absolute URL is set as resourceBase AND Antragsgrün is installed in a subdirectory of the domain, it is required to also set the updaterBase in config.json, pointing to the relative directory of the updater.php script.
Increasing performance by caching in Redis
Redis can be used to cache the changes in amendments, user sessions, and many other aspects of the site. To enable redis, simply add a redis configuration key to the config.json and point it to your setup:
Add the following settings to your config.json (and adapt them to your needs):
{
"redis": {
"hostname": "localhost",
"port": 6379,
"database": 0,
"password": "mysecret" // optional
}
}
OpenTelemetry Integration
OpenTelemetry-Observability requires the PHP OpenTelemetry extension installed, and, optionally (required for PHP 8.5 at the moment) the protobuf extension (see the sample Dockerfile.
Then the libraries:
composer require open-telemetry/sdk open-telemetry/exporter-otlp open-telemetry/opentelemetry-auto-pdo open-telemetry/opentelemetry-auto-curl open-telemetry/opentelemetry-auto-guzzle php-http/guzzle7-adapter
OpenTelemetry could be configured through the php.ini, but will practically rather be configured using environment variables. A very simple sample for this is provided in the docker-compose.development.yml.
If you are running the docker-compose.development.yml for development, a sample collector is included, accessible through http://localhost:55679/debug/tracez .
Client-Side (JavaScrípt) Error Tracking
Error Tracking for Client-Side errors can be enabled, either to a local log file, or via OpenTelemetry. To log to a local file /var/log/antragsgruen/js_error.log, use:
{
"jsErrorTracking": "file:///var/log/antragsgruen/js_error.log"
}
If configuring Antragsgrün using environment variables instead, use the variable JS_ERROR_TRACKING.
To use OpenTelemetry instead of a local log file, simply set the setting to otel://js.error.
Enable background job processing
Some processes that are potentially blocking or long-running can be executed as background jobs, by using a permanently running worker-job that executes these jobs asynchronously.
The following example on how to run the background job processor uses Supervisord, but it is just as possible runni