Run Synapse on localhost in a Debian container.
Note to self: as of Nov 30 2021, I noticed that recent versions of mkosi produce an image missing /etc/resolv.conf
and without working name resolution. Unsure why. In the meantime, the following version works:
python3 -m pip install --user git+https://github.com/systemd/mkosi.git@f9b565e11a7310d69c314f12d4c8d173e3196812
- systemd 233 and systemd-nspawn
- mkosi version 10 (requires Python 3.7)
sudo apt install systemd-container debootstrap debian-archive-keyring
python3 -m pip install --user git+https://github.com/systemd/mkosi.git
- If your distribution lacks
systemd-nspawn
andmachinectl
, install the packagesystemd-container
- Install the packages
debootstrap
anddebian-archive-keyring
, then install mkosi from source
git clone https://github.com/matrix-org/synapse.git
git clone https://github.com/DWeb-Deconstruction-Project/synapse-nspawn.git
cd synapse-nspawn
sudo -E python3 -m mkosi --build-sources ../synapse --minimize
sudo systemd-nspawn --machine synapse --settings trusted
mkosi uses a two-phase process to allow fast incremental builds of code in the container. Run mkosi with the --incremental
flag and with --build-sources
set to the root of your existing Synapse code tree. On subsequent builds, use the --force
flag to install your modified code:
sudo -E python3 -m mkosi --build-sources ../synapse --incremental --force
The image synapse.raw
is created in /var/lib/machines/
, and can be easily booted with systemd-nspawn:
sudo systemd-nspawn --machine synapse --settings trusted
- Ignore the btrfs error at the end of the mkosi build process
- mkosi does not cache the Python packages installed in
mkosi.prepare
, so these packages are downloaded twice during the initial build process - The included Synapse service, sysuser, and tmpfile configs are based on those of the Arch package
- The included systemd log config is from the official Synapse repo