Collecting and presenting stembureaus
docker/docker-compose.yml.example
to docker/docker-compose.yml
and edit it
<DB_PASSWORD>
config.py.example
to config.py
and edit it
<DB_PASSWORD>
as used in docker/docker-compose.yml
<name of election>
values in the 'verkiezingen' field in 'app/data/gemeenten.json'app/data/gemeenten.json.example
to app/data/gemeenten.json
and edit it
app/config.py
docker/docker-entrypoint-initdb.d/
unzip bag-adressen-full-laatst.csv.zip
bag.sql
will automatically load the data when docker starts for the first time; if you want to update the data later the you can simply go to the docker
folder and run sudo ./update_bag.sh
docker/update_bag.sh.example
to docker/update_bag.sh
and edit it
<DB_PASSWORD>
as used in docker/docker-compose.yml
docker/docker-entrypoint-initdb.d
if you want to import it: gunzip latest-mysqldump-daily.sql.gz
cd docker
sudo docker-compose up -d
docker-compose up
command above also loads the BAG data in MySQL, this can take more than 1 hour on a server (without SSD), so wait until WaarIsMijnStemlokaal.nl
loads without errors before continuing with the commands belowsudo docker exec -it stm_app_1 /opt/stm/bin/get_address_data.sh
docker/backup.sh.example
to docker/backup.sh
and edit it
<DB_PASSWORD>
as used in docker/docker-compose.yml
<RESOURCE_ID>
sudo ./backup.sh
sudo crontab -e
and add the following line (change the path below to your stembureaus/docker
directory path)46 3 * * * (cd <PATH_TO_stembureaus/docker> && sudo ./backup.sh)
docker/docker-entrypoint-initdb.d
and the CKAN exports in exports
docker/docker-entrypoint-initdb.d
if you want to import it: gunzip latest-mysqldump-daily.sql.gz
cd docker
sudo docker-compose -f docker-compose.yml -f docker-compose-dev.yml up -d
docker-compose up
command above for the first time or if you removed the stm_stm-mysql-volume
then the BAG data will be loaded in MySQL, this can take something like 15 minutes (with an SSD), so wait until WaarIsMijnStemlokaal.nl
loads without errors before continuing with the commands belowsudo docker exec -it stm_app_1 /opt/stm/bin/get_address_data.sh
sudo docker inspect stm_nginx_1
and add it to your hosts file /etc/hosts
: <IP_address> waarismijnstemlokaal.nl
sudo docker exec -it stm_app_1 nosetests
docker/docker-entrypoint-initdb.d
again), but not the stembureaus data stored in CKAN)
sudo docker-compose down --rmi all && sudo docker volume rm stm_stm-mysql-volume && sudo docker-compose up -d
sudo docker-compose -f docker-compose.yml -f docker-compose-dev.yml down --rmi all && sudo docker volume rm stm_stm-mysql-volume && sudo docker-compose -f docker-compose.yml -f docker-compose-dev.yml up -d
sudo docker exec stm_nginx_1 nginx -s reload
touch uwsgi-touch-reload
sudo docker exec stm_nodejs_1 yarn
Production
static/dist
directory: sudo docker exec stm_nodejs_1 yarn prod
Development
static/dist
directory (with map files): sudo docker exec stm_nodejs_1 yarn dev
sudo docker exec stm_nodejs_1 yarn watch
To access the CLI of the app run sudo docker exec -it stm_app_1 bash
and run flask
, flask ckan
and flask mysql
to see the available commands. Here are some CLI commands:
flask mysql add-admin-user <email>
add a new admin user with the specified emailflask ckan add-new-datastore <ID_of_resource>
add a new datastore in a CKAN resource; this needs to be run once after you've created a new CKAN resource, see Create new CKAN datasets and resources for new electionsflask mysql add-gemeenten-verkiezingen-users
add all gemeenten, verkiezingen and users specified in 'app/data/gemeenten.json' to the MySQL database and send new users an invitation emailsudo docker exec -it stm_mysql_1 bash
mysql -p
docker/docker-compose.yml
and enter it in the promptsudo docker-compose -f docker-compose.yml -f docker-compose-dev.yml build --pull nginx
sudo docker-compose -f docker-compose.yml -f docker-compose-dev.yml up -d nginx
sudo docker-compose build --pull nginx
sudo docker-compose up -d nginx
sudo docker-compose -f docker-compose.yml -f docker-compose-dev.yml build --pull app
sudo docker-compose -f docker-compose.yml -f docker-compose-dev.yml up -d app
sudo docker-compose build --pull app
sudo docker-compose up -d app
sudo docker-compose pull mysql
sudo docker-compose up -d mysql
Use Fabric 2.x on your development machine to pull new changes from GitHub on a server and compile assets
fab deploy
If you try to visit WaarIsMijnStemlokaal.nl and get a '502 Bad Gateway', then open the console in your browser. If you see a message like (this is in Firefox):
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.
or if you see something like this in your Docker logs:
app_1 | invalid request block size: 21573 (max 4096)...skip nginx_1 | 2021/12/20 16:12:40 [error] 30#30: *1 upstream prematurely closed connection while reading response header from upstream, client: 172.18.0.1, server: waarismijnstemlokaal.nl, request: "GET / HTTP/1.1", upstream: "http://172.18.0.3:5000/", host: "waarismijnstemlokaal.nl"
then you are probably mixing up development and production images for the app
and nginx
services (to be precise, nginx uses a normal HTTP request in the development environment, but uses uwsgi in production). Stop and remove the app and nginx containers and remove the app and nginx images. Build again (use the --no-cache
option) and make sure that you use sudo docker-compose -f docker-compose.yml -f docker-compose-dev.yml build --no-cache app nginx
for development and simply sudo docker-compose build --no-cache app nginx
for production.