Skip to content

Commit 917674b

Browse files
potiukdheerajturagaamoghrajesh
authored
[v3-0-test] Common airflow.cfg files across all containers in default docker-compose.yaml (#49681) (#49775)
* Mount airflow project dir to containers airflow home * Remove dags/logs/config/plugin mounts They are no longer needed as we are directly mounting AIRFLOW_HOME * Set AIRFLOW_CFG in common env * Update docs and airflow init step to align with common-env * Fix spell check and static checks --------- (cherry picked from commit ec49402) Co-authored-by: Dheeraj Turaga <[email protected]> Co-authored-by: Amogh Desai <[email protected]>
1 parent dbcd32b commit 917674b

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

airflow-core/docs/howto/docker-compose/docker-compose.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ x-airflow-common:
7171
# for other purpose (development, test and especially production usage) build/extend Airflow image.
7272
_PIP_ADDITIONAL_REQUIREMENTS: ${_PIP_ADDITIONAL_REQUIREMENTS:-}
7373
# The following line can be used to set a custom config file, stored in the local config folder
74-
# If you want to use it, outcomment it and replace airflow.cfg with the name of your config file
75-
# AIRFLOW_CONFIG: '/opt/airflow/config/airflow.cfg'
74+
AIRFLOW_CONFIG: '/opt/airflow/config/airflow.cfg'
7675
volumes:
7776
- ${AIRFLOW_PROJ_DIR:-.}/dags:/opt/airflow/dags
7877
- ${AIRFLOW_PROJ_DIR:-.}/logs:/opt/airflow/logs
@@ -252,8 +251,8 @@ services:
252251
echo " https://airflow.apache.org/docs/apache-airflow/stable/howto/docker-compose/index.html#before-you-begin"
253252
echo
254253
fi
255-
mkdir -p /sources/logs /sources/dags /sources/plugins
256-
chown -R "${AIRFLOW_UID}:0" /sources/{logs,dags,plugins}
254+
mkdir -p /opts/airflow/{logs,dags,plugins,config}
255+
chown -R "${AIRFLOW_UID}:0" /opts/airflow/{logs,dags,plugins,config}
257256
exec /entrypoint airflow version
258257
# yamllint enable rule:line-length
259258
environment:
@@ -264,8 +263,6 @@ services:
264263
_AIRFLOW_WWW_USER_PASSWORD: ${_AIRFLOW_WWW_USER_PASSWORD:-airflow}
265264
_PIP_ADDITIONAL_REQUIREMENTS: ''
266265
user: "0:0"
267-
volumes:
268-
- ${AIRFLOW_PROJ_DIR:-.}:/sources
269266

270267
airflow-cli:
271268
<<: *airflow-common

airflow-core/docs/howto/docker-compose/index.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ Setting the right Airflow user
125125
------------------------------
126126

127127
On **Linux**, the quick-start needs to know your host user id and needs to have group id set to ``0``.
128-
Otherwise the files created in ``dags``, ``logs`` and ``plugins`` will be created with ``root`` user ownership.
129-
You have to make sure to configure them for the docker-compose:
128+
Otherwise the files created in ``dags``, ``logs``, ``config`` and ``plugins`` will be created with
129+
``root`` user ownership. You have to make sure to configure them for the docker-compose:
130130

131131
.. code-block:: bash
132132
@@ -143,6 +143,17 @@ safely ignore it. You can also manually create an ``.env`` file in the same fold
143143
144144
AIRFLOW_UID=50000
145145
146+
Initialize airflow.cfg (Optional)
147+
---------------------------------
148+
149+
If you want to initialize ``airflow.cfg`` with default values before launching the airflow service, run.
150+
151+
.. code-block:: bash
152+
153+
docker compose run airflow-cli airflow config list
154+
155+
This will seed ``airflow.cfg`` with default values in ``config`` folder.
156+
146157
Initialize the database
147158
-----------------------
148159

@@ -346,12 +357,9 @@ Special case - Adding a custom config file
346357

347358
If you have a custom config file and wish to use it in your Airflow instance, you need to perform the following steps:
348359

349-
1) Remove comment from the ``AIRFLOW_CONFIG: '/opt/airflow/config/airflow.cfg'`` line
350-
in the ``docker-compose.yaml`` file.
351-
352-
2) Place your custom ``airflow.cfg`` file in the local config folder.
360+
1) Replace the auto-generated ``airflow.cfg`` file in the local config folder with your custom config file.
353361

354-
3) If your config file has a different name than ``airflow.cfg``, adjust the filename in
362+
2) If your config file has a different name than ``airflow.cfg``, adjust the filename in
355363
``AIRFLOW_CONFIG: '/opt/airflow/config/airflow.cfg'``
356364

357365
Networking

0 commit comments

Comments
 (0)