diff --git a/submatrix/Containerfile b/submatrix/Containerfile index 91d8178c..ad73ebb6 100644 --- a/submatrix/Containerfile +++ b/submatrix/Containerfile @@ -1,25 +1,40 @@ -FROM alpine:3.20 as submatrix +FROM alpine:3.20 as build -RUN apk add \ - synapse \ - envsubst \ - py3-curl \ - tzdata \ - ; +RUN apk update && \ + apk add \ + envsubst \ + && \ + : COPY homeserver.yaml.template /etc/synapse/homeserver.yaml.template -COPY homeserver.log.config /etc/synapse/homeserver.log.config +ARG MATRIX_HOSTNAME -COPY orbit_auth.py /usr/local/share/submatrix/ +RUN envsubst '$MATRIX_HOSTNAME' < /etc/synapse/homeserver.yaml.template > /etc/synapse/homeserver.yaml -COPY start.sh /usr/local/share/submatrix/ +FROM alpine:3.20 as submatrix -ARG MATRIX_HOSTNAME=localhost +COPY --from=build /etc/synapse/homeserver.yaml /etc/synapse/homeserver.yaml -RUN envsubst '$MATRIX_HOSTNAME' < /etc/synapse/homeserver.yaml.template > /etc/synapse/homeserver.yaml +RUN apk update && \ + apk add \ + synapse \ + py3-curl \ + tzdata \ + && \ + : + +COPY homeserver.log.config /etc/synapse/homeserver.log.config + +COPY orbit_auth.py /usr/local/share/submatrix/ + +# forgive the __import__ garbage, you can't start a with block after a semicolon (i.e. import foo; with...) +# this creates a file in the sytem site-packages folder (whose exact location depends on the python version +# and can only be discovered by asking python) that points to our folder for the auth plugin so that our +# folder is added to the python path and synapse will be able to import the module code located in there. +RUN python3 -c 'with open(__import__("pathlib").Path(__import__("site").getsitepackages()[0]) / "custom-site-pkgs.pth", "w") as f: f.write("/usr/local/share/submatrix\n")' USER 100:100 -ENTRYPOINT ["/usr/local/share/submatrix/start.sh"] +ENTRYPOINT ["synapse_homeserver", "-c", "/etc/synapse/homeserver.yaml"] diff --git a/submatrix/start.sh b/submatrix/start.sh deleted file mode 100755 index 0d908cdf..00000000 --- a/submatrix/start.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -export PYTHONPATH="/usr/local/share/submatrix:${PYTHONPATH}" -exec synapse_homeserver -c /etc/synapse/homeserver.yaml