Image build arguments reference¶
The following build arguments (--build-arg
in docker build command) can be used for production images.
Those arguments are used when you want to customize the image. You can see some examples of it in
Building from PyPI packages.
Basic arguments¶
Those are the most common arguments that you use when you want to build a custom image.
Build argument |
Default value |
Description |
---|---|---|
|
|
Base python image. |
|
|
version of Airflow. |
|
(see below the table) |
Default extras with which airflow is installed. |
|
Optional additional extras with which airflow is installed. |
|
|
|
Airflow’s HOME (that’s where logs and SQLite databases are stored). |
|
|
Home directory of the Airflow user. |
|
|
PIP version used. |
|
|
UV version used. |
|
|
Whether to use UV to build the image. This is an experimental feature. |
|
|
Timeout in seconds for UV pull requests. |
|
additional |
|
|
|
Progress bar for PIP installation |
|
|
Airflow user UID. |
|
|
Type of constraints to build the image.
This can be |
|
Reference (branch or tag) from GitHub
where constraints file is taken from
It can be |
Note
Before Airflow 2.2, the image also had AIRFLOW_GID
parameter, but it did not provide any additional
functionality - only added confusion - so it has been removed.
List of default extras in the production Dockerfile:
aiobotocore
amazon
async
celery
cncf-kubernetes
common-io
docker
elasticsearch
fab
ftp
google
google-auth
graphviz
grpc
hashicorp
http
ldap
microsoft-azure
mysql
odbc
openlineage
pandas
postgres
redis
sendgrid
sftp
slack
snowflake
ssh
statsd
uv
virtualenv
Image optimization options¶
The main advantage of Customization method of building Airflow image, is that it allows to build highly optimized image because the final image (RUNTIME) might not contain all the dependencies that are needed to build and install all other dependencies (DEV). Those arguments allow to control what is installed in the DEV image and what is installed in RUNTIME one, thus allowing to produce much more optimized images. See Building optimized images. for examples of using those arguments.
Build argument |
Default value |
Description |
---|---|---|
|
If set to a random, non-empty value the dependencies are upgraded to newer versions. In CI it is set to build id to make sure subsequent builds are not reusing cached images with same value. |
|
|
Optional python packages to extend the image with some extra dependencies. |
|
|
Dev apt command executed before dev deps are installed in the Build image. |
|
|
Additional Dev apt command executed
before dev dep are installed
in the Build image. Should start with
|
|
|
Empty - install default dependencies
(see |
Dev APT dependencies installed in the Build image. |
|
Additional apt dev dependencies installed in the Build image. |
|
|
Additional env variables defined when installing dev deps. |
|
|
Runtime apt command executed before deps
are installed in the |
|
|
Additional Runtime apt command executed
before runtime dep are installed
in the |
|
|
Empty - install default dependencies
(see |
Runtime APT dependencies installed in the Main image. |
|
Additional apt runtime dependencies installed in the Main image. |
|
|
Additional env variables defined when installing runtime deps. |
|
|
|
Whether MySQL client should be installed The mysql extra is removed from extras if the client is not installed. |
|
|
Type of MySQL client library. This
can be |
|
|
Whether MsSQL client should be installed |
|
|
Whether Postgres client should be installed |
Installing Airflow using different methods¶
Those parameters are useful only if you want to install Airflow using different installation methods than the default (installing from PyPI packages).
This is usually only useful if you have your own fork of Airflow and want to build the images locally from those sources - either locally or directly from GitHub sources. This way you do not need to release your Airflow and Providers via PyPI - they can be installed directly from sources or from GitHub repository. Another option of installation is to build Airflow from previously prepared binary Python packages which might be useful if you need to build Airflow in environments that require high levels of security.
- You can see some examples of those in:
Build argument |
Default value |
Description |
---|---|---|
|
|
Installation method of Apache Airflow.
|
|
|
Sources of Airflow. Set it to “.” when you install Airflow from local sources |
|
|
Target for Airflow sources. Set to “/opt/airflow” when you install Airflow from local sources. |
|
Optional - might be used for using limit
for Airflow version installation - for
example |
|
|
If not empty, it will override the
source of the constraints with the
specified URL or file. Note that the
file has to be in Docker context so
it’s best to place such file in
one of the folders included in
|
|
|
|
If set to a folder (for example to
|
|
|
If set to true, Airflow, providers and
all dependencies are installed from
from locally built/downloaded
.whl and .tar.gz files placed in the
|
Pre-caching PIP dependencies¶
When image is build from PIP, by default pre-caching of PIP dependencies is used. This is in order to speed-up incremental
builds during development. When pre-cached PIP dependencies are used and pyproject.toml
changes, the
PIP dependencies are already pre-installed, thus resulting in much faster image rebuild. This is purely an optimization
of time needed to build the images and should be disabled if you want to install Airflow from
Docker context files.
Build argument |
Default value |
Description |
---|---|---|
|
|
the branch from which PIP dependencies are pre-installed initially. |
|
|
the repository from which PIP dependencies are pre-installed. |
|
|
Allows to pre-cache airflow PIP packages from the GitHub of Apache Airflow This allows to optimize iterations for Image builds and speeds up CI builds. |
|
|
Allow to invalidate cache by passing a new argument. |