Separate Facebook bridge configuration and data

Using a separate directory allows easier backups
(only need to back up the Ansible playbook configuration and the
bridge's `./data` directory).

The playbook takes care of migrating an existing database file
from the base directory into the `./data` directory.

In the future, we can also mount the configuration read-only,
to ensure the bridge won't touch it.
For now, mautrix-facebook is keen on rebuilding the `config.yaml`
file on startup though, so this will have to wait.
This commit is contained in:
Slavi Pantaleev
2019-06-07 14:50:55 +03:00
parent 4f0bcc624f
commit 172b0fa88c
3 changed files with 40 additions and 9 deletions

View File

@ -17,9 +17,10 @@ ExecStartPre=/usr/bin/docker run --rm --name matrix-mautrix-facebook-db \
--log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
--cap-drop=ALL \
-v {{ matrix_mautrix_facebook_base_path }}:/data:z \
-v {{ matrix_mautrix_facebook_data_path }}:/data:z \
-v {{ matrix_mautrix_facebook_config_path }}:/config:z \
{{ matrix_mautrix_facebook_docker_image }} \
alembic -x config=/data/config.yaml upgrade head
alembic -x config=/config/config.yaml upgrade head
# Intentional delay, so that the homeserver (we likely depend on) can manage to start.
ExecStartPre=/bin/sleep 5
@ -29,12 +30,13 @@ ExecStart=/usr/bin/docker run --rm --name matrix-mautrix-facebook \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
--cap-drop=ALL \
--network={{ matrix_docker_network }} \
-v {{ matrix_mautrix_facebook_base_path }}:/data:z \
-v {{ matrix_mautrix_facebook_data_path }}:/data:z \
-v {{ matrix_mautrix_facebook_config_path }}:/config:z \
{% for arg in matrix_mautrix_facebook_container_extra_arguments %}
{{ arg }} \
{% endfor %}
{{ matrix_mautrix_facebook_docker_image }} \
python3 -m mautrix_facebook -c /data/config.yaml
python3 -m mautrix_facebook -c /config/config.yaml
ExecStop=-/usr/bin/docker kill matrix-mautrix-facebook
ExecStop=-/usr/bin/docker rm matrix-mautrix-facebook