Skip to content

Commit

Permalink
Add ADDITIONAL_PYTHON_DEPS (apache#9031)
Browse files Browse the repository at this point in the history
* add build-arg ADDITIONAL_PYTHON_DEPS

* Add ADDITIONAL_PYTHON_DEPS example and description

Co-authored-by: Fabian Witt <fabian.witt@redheads.de>
(cherry picked from commit 6fc555d)
  • Loading branch information
wittfabian authored and Chris Fei committed Mar 5, 2021
1 parent 781e3ed commit 7f66dc3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#
ARG AIRFLOW_VERSION="2.0.0.dev0"
ARG AIRFLOW_EXTRAS="async,aws,azure,celery,dask,elasticsearch,gcp,kubernetes,mysql,postgres,redis,slack,ssh,statsd,virtualenv"
ARG ADDITIONAL_PYTHON_DEPS=""

ARG AIRFLOW_HOME=/opt/airflow
ARG AIRFLOW_UID="50000"
Expand Down Expand Up @@ -169,6 +170,9 @@ ENV AIRFLOW_VERSION=${AIRFLOW_VERSION}
ARG AIRFLOW_EXTRAS
ENV AIRFLOW_EXTRAS=${AIRFLOW_EXTRAS}

ARG ADDITIONAL_PYTHON_DEPS
ENV ADDITIONAL_PYTHON_DEPS=${ADDITIONAL_PYTHON_DEPS}

ARG AIRFLOW_INSTALL_SOURCES="."
ENV AIRFLOW_INSTALL_SOURCES=${AIRFLOW_INSTALL_SOURCES}

Expand All @@ -187,6 +191,8 @@ ENV PATH=${PATH}:/root/.local/bin

RUN pip install --user "${AIRFLOW_INSTALL_SOURCES}[${AIRFLOW_EXTRAS}]${AIRFLOW_INSTALL_VERSION}" \
--constraint /requirements.txt && \
if [ -n "${ADDITIONAL_PYTHON_DEPS}" ]; then pip install --user ${ADDITIONAL_PYTHON_DEPS} \
--constraint /requirements.txt; fi && \
find /root/.local/ -name '*.pyc' -print0 | xargs -0 rm -r && \
find /root/.local/ -type d -name '__pycache__' -print0 | xargs -0 rm -r

Expand Down
19 changes: 19 additions & 0 deletions IMAGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ The following build arguments (``--build-arg`` in docker build command) can be u
| ``AIRFLOW_EXTRAS`` | (see Dockerfile) | Default extras with which airflow is |
| | | installed |
+------------------------------------------+------------------------------------------+------------------------------------------+
| ``ADDITIONAL_PYTHON_DEPS`` | (see Dockerfile) | Optional python packages to extend |
| | | the image with some extra dependencies |
+------------------------------------------+------------------------------------------+------------------------------------------+
| ``AIRFLOW_HOME`` | ``/opt/airflow`` | Airflow’s HOME (that’s where logs and |
| | | sqlite databases are stored) |
+------------------------------------------+------------------------------------------+------------------------------------------+
Expand Down Expand Up @@ -365,6 +368,22 @@ requirements taken from v1-10-test branch in Github.
--build-arg AIRFLOW_SOURCES_FROM="entrypoint.sh" \
--build-arg AIRFLOW_SOURCES_TO="/entrypoint"
This builds the production image in version 3.7 with default airflow extras from 1.10.10 Pypi package and
additional python dependencies.

.. code-block::
docker build . \
--build-arg PYTHON_BASE_IMAGE="python:3.7-slim-buster" \
--build-arg PYTHON_MAJOR_MINOR_VERSION=3.7 \
--build-arg AIRFLOW_INSTALL_SOURCES="apache-airflow" \
--build-arg AIRFLOW_INSTALL_VERSION="==1.10.10" \
--build-arg CONSTRAINT_REQUIREMENTS="https://raw.githubusercontent.com/apache/airflow/1.10.10/requirements/requirements-python3.7.txt" \
--build-arg ENTRYPOINT_FILE="https://raw.githubusercontent.com/apache/airflow/1.10.10/entrypoint.sh" \
--build-arg AIRFLOW_SOURCES_FROM="entrypoint.sh" \
--build-arg AIRFLOW_SOURCES_TO="/entrypoint" \
--build-arg ADDITIONAL_PYTHON_DEPS="sshtunnel oauth2client"
Image manifests
---------------

Expand Down

0 comments on commit 7f66dc3

Please sign in to comment.