diff --git a/alpine-matrix/build.sh b/alpine-matrix/build.sh new file mode 100644 index 0000000..409d1ac --- /dev/null +++ b/alpine-matrix/build.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +ROOTFS=rootfs + +wget http://dl-cdn.alpinelinux.org/alpine/v3.9/releases/x86_64/alpine-minirootfs-3.9.0-x86_64.tar.gz +mkdir -p $ROOTFS + +tar xf alpine-minirootfs-3.9.0-x86_64.tar.gz -C $ROOTFS/ \ + ./etc/apk ./etc/os-release ./usr ./lib ./bin ./sbin ./var + +mkdir -p $ROOTFS/etc/systemd/system \ + $ROOTFS/var/{lib,run,tmp} \ + $ROOTFS/{dev,tmp,proc,root,run,sys} \ + $ROOTFS/{var/lib,var/log,etc}/synapse +touch $ROOTFS/etc/machine-id $ROOTFS/etc/resolv.conf + +cp install.sh $ROOTFS/root/ +sudo systemd-nspawn -D $ROOTFS/ /bin/sh /root/install.sh + +cp *.service $ROOTFS/etc/systemd/system/ + +mksquashfs $ROOTFS/ synapse.raw diff --git a/alpine-matrix/install.sh b/alpine-matrix/install.sh new file mode 100644 index 0000000..ffc3e7d --- /dev/null +++ b/alpine-matrix/install.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +apk --no-cache add --virtual .synapse-build \ + build-base \ + git \ + libevent-dev \ + libffi-dev \ + libjpeg-turbo-dev \ + libressl-dev \ + libxslt-dev \ + linux-headers \ + npm \ + python3-dev \ + zlib-dev + +pip3 install --upgrade pip setuptools +pip3 install https://github.com/matrix-org/synapse/tarball/master +pip3 install mautrix-telegram + +npm install matrix-appservice-irc --global + +apk del .synapse-build + +# Runtime packages. +apk --no-cache add \ + libjpeg-turbo \ + libmagic \ + libressl2.7-libssl \ + nodejs \ + python3 + +find /usr -name "__pycache__" -exec rm -rf {} + +find /usr -name "*.pyc" -exec rm {} + +rm -rf /root/.cache \ + /root/.config \ + /root/.npm \ + /etc/apk diff --git a/alpine-matrix/synapse.service b/alpine-matrix/synapse.service new file mode 100644 index 0000000..8d40e2f --- /dev/null +++ b/alpine-matrix/synapse.service @@ -0,0 +1,15 @@ +[Unit] +Description=Synapse Matrix homeserver +After=network-online.target +Requires=network-online.target + +[Service] +Environment=LANG=en_US.UTF-8 +Environment=SYNAPSE_LOG_LEVEL=DEBUG +Environment=PYTHONDONTWRITEBYTECODE=1 + +ExecStart=/usr/bin/python3 -m synapse.app.homeserver -c /etc/synapse/homeserver.yaml +ExecStop=/usr/bin/synctl stop /etc/synapse/homeserver.yaml + +StateDirectory=synapse +ConfigurationDirectory=synapse