From 155526bc14e72a7d81d5305cb63eb44922d775de Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 1 Mar 2020 13:53:10 +0200 Subject: [PATCH] Improve dockerfile and update mautrix-python --- Dockerfile | 27 +++++++++++++++------------ Dockerfile.ci | 27 +++++++++++++++------------ requirements.txt | 26 +++++++++++++------------- setup.py | 20 ++++---------------- 4 files changed, 47 insertions(+), 53 deletions(-) diff --git a/Dockerfile b/Dockerfile index aee0608..9c08f15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,7 @@ RUN cd /frontend && yarn --prod && yarn build FROM alpine:3.11 -COPY requirements.txt /opt/maubot/requirements.txt -WORKDIR /opt/maubot -RUN apk add --no-cache --virtual .build-deps \ - python3-dev \ - build-base \ - git \ - && apk add --no-cache \ +RUN apk add --no-cache \ ca-certificates \ su-exec \ py3-aiohttp \ @@ -19,19 +13,28 @@ RUN apk add --no-cache --virtual .build-deps \ py3-attrs \ py3-bcrypt \ py3-cffi \ - py3-pillow \ - py3-magic \ py3-psycopg2 \ py3-ruamel.yaml \ py3-jinja2 \ py3-click \ py3-packaging \ py3-markdown \ - && pip3 install -r requirements.txt \ - feedparser dateparser langdetect python-gitlab \ - && apk del .build-deps + py3-pillow \ + py3-magic \ + py3-feedparser # TODO remove pillow, magic and feedparser when maubot supports installing dependencies +COPY requirements.txt /opt/maubot/requirements.txt +WORKDIR /opt/maubot +RUN apk add --virtual .build-deps \ + python3-dev \ + build-base \ + git \ + && pip3 install -r requirements.txt \ + dateparser langdetect python-gitlab \ + && apk del .build-deps +# TODO also remove dateparser, langdetect and python-gitlab when maubot supports installing dependencies + COPY . /opt/maubot COPY ./docker/mbc.sh /usr/local/bin/mbc COPY --from=frontend-builder /frontend/build /opt/maubot/frontend diff --git a/Dockerfile.ci b/Dockerfile.ci index 76f3e1c..3a9afa3 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -1,12 +1,6 @@ FROM alpine:3.11 -COPY requirements.txt /opt/maubot/requirements.txt -WORKDIR /opt/maubot -RUN apk add --no-cache --virtual .build-deps \ - python3-dev \ - build-base \ - git \ - && apk add --no-cache \ +RUN apk add --no-cache \ ca-certificates \ su-exec \ py3-aiohttp \ @@ -14,19 +8,28 @@ RUN apk add --no-cache --virtual .build-deps \ py3-attrs \ py3-bcrypt \ py3-cffi \ - py3-pillow \ - py3-magic \ py3-psycopg2 \ py3-ruamel.yaml \ py3-jinja2 \ py3-click \ py3-packaging \ py3-markdown \ - && pip3 install -r requirements.txt \ - feedparser dateparser langdetect python-gitlab \ - && apk del .build-deps + py3-pillow \ + py3-magic \ + py3-feedparser # TODO remove pillow, magic and feedparser when maubot supports installing dependencies +COPY requirements.txt /opt/maubot/requirements.txt +WORKDIR /opt/maubot +RUN apk add --virtual .build-deps \ + python3-dev \ + build-base \ + git \ + && pip3 install -r requirements.txt \ + dateparser langdetect python-gitlab \ + && apk del .build-deps +# TODO also remove dateparser, langdetect and python-gitlab when maubot supports installing dependencies + COPY . /opt/maubot COPY ./docker/mbc.sh /usr/local/bin/mbc ENV UID=1337 GID=1337 XDG_CONFIG_HOME=/data diff --git a/requirements.txt b/requirements.txt index b32f18f..fc97360 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,14 @@ -mautrix -aiohttp -SQLAlchemy -alembic -commonmark -ruamel.yaml -attrs -bcrypt -packaging +mautrix==0.5.0.beta1 +aiohttp>=3,<4 +SQLAlchemy>=1,<2 +alembic>=1,<2 +commonmark>=0.9,<1 +ruamel.yaml>=0.15.35,<0.17 +attrs>=18.1.0 +bcrypt>=3,<4 +packaging>=10 -click -colorama -PyInquirer -jinja2 +click>=7,<8 +colorama>=0.4,<0.5 +PyInquirer>=1,<2 +jinja2>=2,<3 diff --git a/setup.py b/setup.py index 7ae94a4..a1f0ba4 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,9 @@ import setuptools import glob import os +with open("requirements.txt") as reqs: + install_requires = reqs.read().splitlines() + path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "maubot", "__meta__.py") __version__ = "UNKNOWN" with open(path) as f: @@ -21,22 +24,7 @@ setuptools.setup( packages=setuptools.find_packages(), - install_requires=[ - "mautrix>=0.4,<0.5", - "aiohttp>=3.0.1,<4", - "SQLAlchemy>=1.2.3,<2", - "alembic>=1.0.0,<2", - "commonmark>=0.9.1,<1", - "ruamel.yaml>=0.15.35,<0.17", - "attrs>=18.1.0", - "bcrypt>=3.1.4,<4", - "packaging>=10", - - "click>=7,<8", - "colorama>=0.4,<0.5", - "PyInquirer>=1,<2", - "jinja2>=2,<3", - ], + install_requires=install_requires, classifiers=[ "Development Status :: 3 - Alpha",