Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/apache-airflow/howto/docker-compose/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,40 @@ to rebuild the images on-the-fly when you run other ``docker compose`` commands.
Examples of how you can extend the image with custom providers, python packages,
apt packages and more can be found in :doc:`Building the image <docker-stack:build>`.

Special case - adding dependencies via requirements.txt file
============================================================

Usual case for custom images, is when you want to add a set of requirements to it - usually stored in
``requirements.txt`` file. For development, you might be tempted to add it dynamically when you are
starting the original airflow image, but this has a number of side effects (for example your containers
will start much slower - each additional dependency will further delay your containers start up time).
Also it is completely unnecessary, because docker compose has the development workflow built-in.
You can - following the previous chapter, automatically build and use your custom image when you
iterate with docker compose locally. Specifically when you want to add your own requirement file,
you should do those steps:

1) Comment out the ``image: ...`` line and remove comment from the ``build: .`` line in the
``docker-compose.yaml`` file. The relevant part of the docker-compose file of yours should look similar
to (use correct image tag):

```
#image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.5.1}
build: .
```

2) Create ``Dockerfile`` in the same folder your ``docker-compose.yaml`` file is with content similar to:

```
FROM apache/airflow:2.5.1
ADD requirements.txt .
RUN pip install -r requirements.txt
```

3) Place ``requirements.txt`` file in the same directory.

Run ``docker compose build`` to build the image, or add ``--build`` flag to ``docker compose up`` or
``docker compose run`` commands to build the image automatically as needed.

Networking
==========

Expand Down