diff --git a/Dockerfile b/Dockerfile index 5fc4bd7..7fb2ca5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,12 +14,31 @@ ENV APPRISE_ATTACH_DIR=/attach ENV APPRISE_PLUGIN_PATHS=/plugin ENV TZ=Etc/UTC +FROM base AS builder + +# python-qpid-proton (AMQP 1.0) is installed here rather than through +# requirements.txt because it must be compiled on Linux +COPY ./requirements.txt /etc/requirements.txt + +RUN set -eux && \ + echo "Installing build tools" && \ + apt-get update -qq && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \ + build-essential pkg-config libssl-dev git && \ + echo "Building python wheels" && \ + pip3 wheel --no-cache-dir -q --wheel-dir /wheels \ + -r /etc/requirements.txt gunicorn supervisor \ + python-qpid-proton + FROM base AS runtime # Install requirements and gunicorn COPY ./requirements.txt /etc/requirements.txt -RUN set -eux && \ +# The wheels from the builder are only mounted while installing, so they +# do not take up space in the final image +RUN --mount=type=bind,from=builder,source=/wheels,target=/wheels \ + set -eux && \ echo "Installing nginx" && \ apt-get update -qq && \ DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \ @@ -29,7 +48,9 @@ RUN set -eux && \ apt-get install -y -qq \ curl sed git && \ echo "Installing python requirements" && \ - pip3 install --no-cache-dir -q -r /etc/requirements.txt gunicorn supervisor && \ + pip3 install --no-cache-dir -q --no-index --find-links /wheels \ + -r /etc/requirements.txt gunicorn supervisor \ + python-qpid-proton && \ pip freeze && \ echo "Cleaning up" && \ apt-get --yes autoremove --purge && \ diff --git a/pyproject.toml b/pyproject.toml index 2ed4b44..5360860 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,8 @@ dependencies = [ "PGPy", "smpplib", "slixmpp >= 1.16.0", + # Provides amqp:// support for AMQP 0.9.1 + "pika", ] [project.urls] diff --git a/requirements.txt b/requirements.txt index f85f30d..738d6f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,6 +32,10 @@ PGPy smpplib # For xmpp:// support slixmpp >= 1.16.0 +# Provides amqp:// support for AMQP 0.9.1 +pika +# AMQP 1.0 (python-qpid-proton) must be compiled on Linux, so only the +# Docker image installs it. Add it with: pip install python-qpid-proton # prometheus metrics django-prometheus