Update docker setup

This commit is contained in:
Tulir Asokan 2018-10-18 15:31:18 +03:00
parent 3337ac52ea
commit ac5f059ef4
2 changed files with 4 additions and 14 deletions

View File

@ -1,18 +1,12 @@
FROM alpine:3.8 FROM alpine:3.8
ENV UID=1338 \
GID=1338
COPY . /opt/maubot COPY . /opt/maubot
WORKDIR /opt/maubot WORKDIR /opt/maubot
RUN apk add --no-cache \ RUN apk add --no-cache \
python3-dev \
build-base \
py3-aiohttp \ py3-aiohttp \
py3-sqlalchemy \ py3-sqlalchemy \
py3-attrs \ py3-attrs \
ca-certificates \ ca-certificates \
su-exec \
&& pip3 install -r requirements.txt && pip3 install -r requirements.txt
VOLUME /data VOLUME /data

View File

@ -1,15 +1,13 @@
#!/bin/sh #!/bin/sh
# Define functions.
function fixperms {
chown -R $UID:$GID /data /opt/maubot
}
cd /opt/maubot cd /opt/maubot
# Replace database path in config. # Replace database path in config.
sed -i "s#sqlite:///maubot.db#sqlite:////data/maubot.db#" /data/config.yaml sed -i "s#sqlite:///maubot.db#sqlite:////data/maubot.db#" /data/config.yaml
sed -i "s#- ./plugins#- /data/plugins#" /data/config.yaml sed -i "s#- ./plugins#- /data/plugins#" /data/config.yaml
sed -i "s#./logs/maubot.log#/var/log/maubot/maubot.log#" /data/config.yaml
mkdir -p /var/log/maubot
# Check that database is in the right state # Check that database is in the right state
alembic -x config=/data/config.yaml upgrade head alembic -x config=/data/config.yaml upgrade head
@ -20,9 +18,7 @@ if [ ! -f /data/config.yaml ]; then
echo "Copied default config file to /data/config.yaml" echo "Copied default config file to /data/config.yaml"
echo "Modify that config file to your liking." echo "Modify that config file to your liking."
echo "Start the container again after that to generate the registration file." echo "Start the container again after that to generate the registration file."
fixperms
exit exit
fi fi
fixperms python3 -m maubot -c /data/config.yaml
exec su-exec $UID:$GID python3 -m maubot -c /data/config.yaml