GatewayNode

Building a Matrix home server I can maintain: part 1 the docker file

So ideally all of our infrastructure would be serverless, with Amazon managing all the backend bits and we'd just work with the important stuff. But sadly Matrix is too new of an ecosystem for this to even really be in Amazon's view as a product offering. Really, who wants communication control enough to maintain a server? It's a pretty small audience. But I'm building something so we are going to have to maintain some infrastructure. but we can get rid of some of the maintenance by building our server in a Docker container.

Note

Some people call container services like AWS Fargate and AWS ECS serverless, they are not. At least not fully, maybe they are semi-serverless, we still have all our dependencies and core application to maintain ourselves. Sure we don't worry about much, especially in Fargate, but we still need an automated build pipeline to keep our container image up to date, and this is something that will need attention when it breaks.

I didn't get very far this week as I have a nasty bit of code I'm wrestling with at work that just caved in to my persistence yesterday. But I did manage to get 2 Docker files that both half work, and I think it's opposing halves. One is from matrixdotorg(according to docker hub) that I just started modifying and the other I built from scratch.

Note

I use the Docker edge (nightly builds or some such), so some of the things I see as broken might not be broken to anyone else... yet.

This one based on the matrixdotorg Docker file get's the Alpine build correct but the Synapse build fails as it seems to be in the wrong directory (I added certbot dep, WORKDIR, and the pwd ls as I work through it). It's also missing instructions about having to checkout the repo first for the copy to work and there is a missing docker hub manifest, so you can't pull it directly in Docker yet.

FROM docker.io/python:2-alpine3.7

RUN apk add --no-cache --virtual .nacl_deps su-exec build-base libffi-dev zlib-dev libressl-dev libjpeg-turbo-dev linux-headers postgresql-dev libxslt-dev certbot

COPY synapse ./
WORKDIR /synapse

# A wheel cache may be provided in ./cache for faster build
RUN pip install --upgrade pip setuptools psycopg2 lxml \
 && mkdir -p /synapse/cache \
 && pwd \
 && ls \
 && pip install -f /synapse/cache --upgrade --process-dependency-links . \
 && mv /synapse/contrib/docker/start.py /synapse/contrib/docker/conf / \
 && rm -rf setup.py setup.cfg synapse

VOLUME ["/data"]

EXPOSE 8008/tcp 8448/tcp

ENTRYPOINT ["/start.py"]

This one I built from scratch by following the matrix.org install instructions but haven't finished the entry point starting script and ports. So I think I'l merge the working parts and we'll have a good docker file... at least, that's the plan.

FROM python:2.7.15-stretch
ADD . /synapse
WORKDIR /synapse
EXPOSE 8448
RUN apt-get update && apt-get install -y \
  libffi-dev \
  libssl-dev \
  libjpeg-dev \
  libxslt1-dev; \
  certbot \
  pip install --upgrade setuptools; \
  pip install https://github.com/matrix-org/synapse/tarball/master;
ENTRYPOINT  python -m synapse.app.homeserver \
  --server-name matrix.localhost \
  --config-path homeserver.yaml \
  --generate-config \
  --report-stats=no;
Ouroboros, you know the snake that eats itself...