commit 71518d79217bd95af61e2a41d59580de8d883dd0 Author: Jan Christian Grünhage Date: Fri Jan 27 19:56:04 2017 +0100 Initial Commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c95985e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM alpine:edge +MAINTAINER Jan Christian Grünhage + +RUN apk add --update \ + python2 \ + py-pip \ + py-virtualenv \ + py-setuptools \ + python-dev \ + postgresql-dev \ + build-base \ + linux-headers \ + libffi-dev \ + jpeg-dev \ + tiff-dev \ + bash \ + sqlite \ + su-exec \ + openldap-dev \ + && virtualenv -p python2.7 /synapse \ + && source /synapse/bin/activate \ + && pip install --upgrade \ + setuptools \ + cffi \ + incremental \ + python-ldap \ + psycopg2 \ + && pip install https://github.com/matrix-org/synapse/tarball/master \ + && mkdir /data + +ADD root / +VOLUME /data +EXPOSE 8448 8008 + +ENTRYPOINT ["/usr/local/bin/run.sh"] +CMD ["start"] diff --git a/root/usr/local/bin/run.sh b/root/usr/local/bin/run.sh new file mode 100755 index 0000000..f72ce2a --- /dev/null +++ b/root/usr/local/bin/run.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +COMMAND="${1}" + +prepare() { + chown ${UID}:${GID} /data + cd /synapse + source bin/activate +} + +case ${COMMAND} in + "start") + prepare + su-exec ${UID}:${GID} python2 -m synapse.app.homeserver \ + --config-path /data/config/homeserver.yaml + ;; + "generate") + breakup="0" + [[ -z "${SERVER_NAME}" ]] && echo "STOP! environment variable SERVER_NAME must be set" && breakup="1" + [[ -z "${REPORT_STATS}" ]] && echo "STOP! environment variable REPORT_STATS must be set to 'no' or 'yes'" && breakup="1" + [[ "${breakup}" == "1" ]] && exit 1 + + [[ "${REPORT_STATS}" != "yes" ]] && [[ "${REPORT_STATS}" != "no" ]] && \ + echo "STOP! REPORT_STATS needs to be 'no' or 'yes'" && breakup="1" + prepare + su-exec ${UID}:${GID} python2 -m synapse.app.homeserver \ + -c /data/config/homeserver.yaml \ + --generate-config \ + -H ${SERVER_NAME} \ + --report-stats ${REPORT_STATS} + ;; +esac