Remove all gateways except IRC, build in /tmp

This commit is contained in:
Vladan Popovic 2019-03-04 21:39:39 +01:00
parent ba082370f9
commit be2fcaedfa
2 changed files with 16 additions and 23 deletions

View file

@ -1,8 +1,8 @@
Matrix synapse service with IRC and Telegram gateways Matrix synapse service with IRC and Telegram gateways
===================================================== =====================================================
A collection of systemd services that run synapse, matrix-appservice-irc A collection of systemd services that run synapse and the IRC gateway
and mautrix-telegram in a read-only alpine squashfs image. (matrix-appservice-irc) in an isolated read-only alpine squashfs image.
Building the squashfs image Building the squashfs image
--------------------------- ---------------------------
@ -13,12 +13,11 @@ Run:
$ sh build.sh $ sh build.sh
``` ```
It will create a rootfs/ folder with an alpine filesystem, install It will create a rootfs/ folder with an alpine filesystem, install synapse,
synapse, matrix-appservice-irc and mautrix-telegram and compress it into matrix-appservice-irc and compress it into a squashfs image that will be used
a squashfs image that will be used as a root filesystem for the as a root filesystem for the container.
container.
If the script finished successfully, you should get an \~50M matrix.raw If the script finished successfully, you should get an \~45M matrix.raw
image. image.
Running the portable services Running the portable services
@ -36,21 +35,17 @@ Created directory /etc/systemd/system.attached/matrix.service.d.
Written /etc/systemd/system.attached/matrix.service.d/20-portable.conf. Written /etc/systemd/system.attached/matrix.service.d/20-portable.conf.
Created symlink /etc/systemd/system.attached/matrix.service.d/10-profile.conf → /usr/lib/systemd/portable/profile/default/service.conf. Created symlink /etc/systemd/system.attached/matrix.service.d/10-profile.conf → /usr/lib/systemd/portable/profile/default/service.conf.
Copied /etc/systemd/system.attached/matrix.service. Copied /etc/systemd/system.attached/matrix.service.
Created directory /etc/systemd/system.attached/matrix-telegram.service.d.
Written /etc/systemd/system.attached/matrix-telegram.service.d/20-portable.conf.
Created symlink /etc/systemd/system.attached/matrix-telegram.service.d/10-profile.conf → /usr/lib/systemd/portable/profile/default/service.conf.
Copied /etc/systemd/system.attached/matrix-telegram.service.
Created directory /etc/systemd/system.attached/matrix-appservice-irc.service.d. Created directory /etc/systemd/system.attached/matrix-appservice-irc.service.d.
Written /etc/systemd/system.attached/matrix-appservice-irc.service.d/20-portable.conf. Written /etc/systemd/system.attached/matrix-appservice-irc.service.d/20-portable.conf.
Created symlink /etc/systemd/system.attached/matrix-appservice-irc.service.d/10-profile.conf → /usr/lib/systemd/portable/profile/default/service.conf. Created symlink /etc/systemd/system.attached/matrix-appservice-irc.service.d/10-profile.conf → /usr/lib/systemd/portable/profile/default/service.conf.
Copied /etc/systemd/system.attached/matrix-appservice-irc.service. Copied /etc/systemd/system.attached/matrix-appservice-irc.service.
Created symlink /etc/portables/matrix.raw → /home/vladan/dev/portabled/alpine-matrix/matrix.raw. Created symlink /etc/portables/matrix.raw → /tmp/matrix.raw.
```
Start/Stop as any other systemd service, e.g: Start/Stop as any other systemd service, e.g:
``` {.sourceCode .shell} ``` {.sourceCode .shell}
sudo systemctl start matrix-appservice-irc.service matrix-telegram.service sudo systemctl start matrix-appservice-irc.service
sudo systemctl stop matrix.service sudo systemctl stop matrix.service
``` ```
@ -63,19 +58,18 @@ Existing matrix installations
`/var/lib`. `/var/lib`.
4. Copy all data files, e.g. homeserver.db if you\'re using sqlite, 4. Copy all data files, e.g. homeserver.db if you\'re using sqlite,
media and upload folders for synapse, rooms.db for the irc gateway, media and upload folders for synapse, rooms.db for the irc gateway,
etc. to `/var/lib/matrix-{synapse,telegram,appservice-irc}`. etc. to `/var/lib/matrix-{synapse,appservice-irc}`.
Warning Warning
------- -------
You\'ll need to modify the configuration if the services are configured You should set up all logging to stdout.
to log to disk, i.e. modify any filesystem except
`/var/lib/matrix-{synapse,telegram,appservice-irc}`. Any configuration that has something to do with the filesystem should be
configured to write files to `/var/lib/matrix-{synapse,appservice-irc}`.
TODO TODO
---- ----
- Use a Makefile to build the image. Add attach, detach and clean - Use a Makefile to build the image. Add attach, detach and clean
targets. targets.
- Rename matrix.service to matrix-synapse.service and add
matrix.target that starts matrix.service

View file

@ -13,11 +13,10 @@ mkdir -p $ROOTFS/etc/systemd/system \
$ROOTFS/{dev,tmp,proc,root,run,sys} \ $ROOTFS/{dev,tmp,proc,root,run,sys} \
$ROOTFS/etc/matrix \ $ROOTFS/etc/matrix \
$ROOTFS/var/lib/matrix-{synapse,appservice-irc} $ROOTFS/var/lib/matrix-{synapse,appservice-irc}
touch $ROOTFS/etc/machine-id $ROOTFS/etc/resolv.conf
touch $ROOTFS/etc/machine-id $ROOTFS/etc/resolv.conf touch $ROOTFS/etc/machine-id $ROOTFS/etc/resolv.conf
sudo systemd-nspawn --bind=$PWD/scripts/install.sh:/root/install.sh -D $ROOTFS/ /bin/sh /root/install.sh
cp systemd/* $ROOTFS/etc/systemd/system/ cp systemd/* $ROOTFS/etc/systemd/system/
sudo systemd-nspawn --bind=$PWD/scripts/install.sh:/root/install.sh -D $ROOTFS/ /bin/sh /root/install.sh
mksquashfs $ROOTFS/ /tmp/matrix.raw mksquashfs $ROOTFS/ /tmp/matrix.raw