Skip to content

Commit

Permalink
Simplify docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jul 14, 2018
1 parent 2aa0ed3 commit b4dd05a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.editorconfig
.codeclimate.yml
*.png
*.md
18 changes: 8 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
FROM docker.io/alpine:3.7
FROM docker.io/alpine:3.8

ENV UID=1337 \
GID=1337
GID=1337 \
FFMPEG_BINARY=/usr/bin/ffmpeg

COPY . /opt/mautrixtelegram
COPY . /opt/mautrix-telegram
WORKDIR /opt/mautrix-telegram
RUN apk add --no-cache \
python3-dev \
build-base \
py3-virtualenv \
py3-pillow \
py3-aiohttp \
Expand All @@ -14,17 +17,12 @@ RUN apk add --no-cache \
py3-numpy \
py3-asn1crypto \
py3-sqlalchemy \
build-base \
py3-markdown \
ffmpeg \
bash \
ca-certificates \
su-exec \
s6 \
&& cd /opt/mautrixtelegram \
&& cp -r docker/root/* / \
&& rm docker -rf \
&& pip3 install -r requirements.txt -r optional-requirements.txt

VOLUME /data

CMD ["/bin/s6-svscan", "/etc/s6.d"]
CMD ["/opt/mautrix-telegram/run.sh"]
22 changes: 11 additions & 11 deletions docker/root/etc/s6.d/mautrix-telegram/run → docker-run.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/bin/bash
#!/bin/sh

# Define functions
# Define functions.
function fixperms {
chown -R ${UID}:${GID} /data /opt/mautrixtelegram
chown -R $UID:$GID /data /opt/mautrix-telegram
}


# Go into env
cd /opt/mautrixtelegram
export FFMPEG_BINARY=/usr/bin/ffmpeg
cd /opt/mautrix-telegram

# Replace database path in config.
sed -i "s#sqlite:///mautrix-telegram.db#sqlite:////data/mautrix-telegram.db#" /data/config.yaml

if [ -f /data/mx-state.json ]; then
ln -s /data/mx-state.json
fi
# Check that database is in the right state
alembic -x config=/data/config.yaml upgrade head

if [[ ! -f /data/config.yaml ]]; then
if [ ! -f /data/config.yaml ]; then
cp example-config.yaml /data/config.yaml
echo "Didn't find a config file."
echo "Copied default config file to /data/config.yaml"
Expand All @@ -26,14 +26,14 @@ if [[ ! -f /data/config.yaml ]]; then
exit
fi

if [[ ! -f /data/registration.yaml ]]; then
if [ ! -f /data/registration.yaml ]; then
python3 -m mautrix_telegram -g -c /data/config.yaml -r /data/registration.yaml
echo "Didn't find a registration file."
echo "Generated ode for you."
echo "Generated one for you."
echo "Copy that over to synapses app service directory."
fixperms
exit
fi

fixperms
exec su-exec ${UID}:${GID} python3 -m mautrix_telegram -c /data/config.yaml
exec su-exec $UID:$GID python3 -m mautrix_telegram -c /data/config.yaml
1 change: 0 additions & 1 deletion docker/root/etc/s6.d/.s6-svscan/finish

This file was deleted.

2 changes: 0 additions & 2 deletions docker/root/etc/s6.d/mautrix-telegram/finish

This file was deleted.

0 comments on commit b4dd05a

Please sign in to comment.