Browse Source

feat: migrate to baseimage

master
Jan Christian Grünhage 3 years ago
parent
commit
f7868ae828
Signed by: jcgruenhage GPG Key ID: 6594C449C633D10C
  1. 6
      .drone.yml
  2. 63
      Dockerfile
  3. 2
      root/etc/s6.d/synapse/finish
  4. 4
      root/etc/s6.d/synapse/run
  5. 17
      root/usr/local/bin/generate
  6. 32
      root/usr/local/bin/run.sh

6
.drone.yml

@ -0,0 +1,6 @@
pipeline:
docker:
image: plugins/docker
repo: docker.jcg.re/synapse
registry: docker.jcg.re
secrets: [ docker_username, docker_password ]

63
Dockerfile

@ -1,36 +1,31 @@
FROM alpine:edge
MAINTAINER Jan Christian Grünhage
FROM docker.jcg.re/base-alpine
MAINTAINER Jan Christian Grünhage <jan.christian@gruenhage.xyz>
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
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 \
&& 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"]
ADD root /
VOLUME /data
EXPOSE 8448 8008

2
root/etc/s6.d/synapse/finish

@ -0,0 +1,2 @@
#!/bin/sh
exec /bin/true

4
root/etc/s6.d/synapse/run

@ -0,0 +1,4 @@
#!/bin/sh
cd /data
exec su-exec ${UID}:${GID} python2 -m synapse.app.homeserver \
--config-path /data/config/homeserver.yaml

17
root/usr/local/bin/generate

@ -0,0 +1,17 @@
#!/bin/sh
chown ${UID}:${GID} /data
[[ -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"
[[ "${REPORT_STATS}" != "yes" ]] && [[ "${REPORT_STATS}" != "no" ]] && \
echo "STOP! REPORT_STATS needs to be 'no' or 'yes'" && breakup="1"
[[ "${breakup}" == "1" ]] && exit 1
su-exec ${UID}:${GID} python2 -m synapse.app.homeserver \
-c /data/config/homeserver.yaml \
--generate-config \
-H ${SERVER_NAME} \
--report-stats ${REPORT_STATS}
sed -e 's#/homeserver.db#/data/database/homeserver.db#' \
-e 's#/homeserver.log#/data/log/homeserver.log#' \
-e 's#/media_store#/data/media_store#' \
-e 's#/uploads#/data/uploads#' -i /data/config/homeserver.yaml

32
root/usr/local/bin/run.sh

@ -1,32 +0,0 @@
#!/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
Loading…
Cancel
Save