update dag sync code
This commit is contained in:
parent
cb512286c1
commit
5ec0941dc7
1 changed files with 30 additions and 7 deletions
|
|
@ -12,35 +12,58 @@ services:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
git_sync:
|
||||||
|
container_name: airflow_git_sync
|
||||||
|
image: registry.k8s.io/git-sync/git-sync:v3.6.7
|
||||||
|
environment:
|
||||||
|
GIT_SYNC_REPO: ${GIT_REPO_URL}
|
||||||
|
GIT_SYNC_BRANCH: main
|
||||||
|
GIT_SYNC_ROOT: /git
|
||||||
|
GIT_SYNC_DEST: repo
|
||||||
|
GIT_SYNC_WAIT: 30
|
||||||
|
GIT_SYNC_ONE_TIME: "false"
|
||||||
|
volumes:
|
||||||
|
- airflow_git:/git
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
airflow:
|
airflow:
|
||||||
container_name: airflow_container
|
container_name: airflow_container
|
||||||
image: apache/airflow:3.1.3
|
image: apache/airflow:3.1.3
|
||||||
ports:
|
ports:
|
||||||
- ${AIRFLOW_PORT}:8080
|
- ${AIRFLOW_PORT}:8080
|
||||||
environment:
|
environment:
|
||||||
# Database connection
|
|
||||||
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
|
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
|
||||||
|
|
||||||
# Custom admin credentials
|
|
||||||
AIRFLOW__WEBSERVER__DEFAULT_USER_USERNAME: ${AIRFLOW_ADMIN_USER}
|
AIRFLOW__WEBSERVER__DEFAULT_USER_USERNAME: ${AIRFLOW_ADMIN_USER}
|
||||||
AIRFLOW__WEBSERVER__DEFAULT_USER_PASSWORD: ${AIRFLOW_ADMIN_PASSWORD}
|
AIRFLOW__WEBSERVER__DEFAULT_USER_PASSWORD: ${AIRFLOW_ADMIN_PASSWORD}
|
||||||
|
|
||||||
# Airflow config
|
|
||||||
AIRFLOW__CORE__LOAD_EXAMPLES: "false"
|
AIRFLOW__CORE__LOAD_EXAMPLES: "false"
|
||||||
AIRFLOW__CORE__EXECUTOR: LocalExecutor
|
AIRFLOW__CORE__EXECUTOR: LocalExecutor
|
||||||
AIRFLOW__WEBSERVER__EXPOSE_CONFIG: "true"
|
AIRFLOW__WEBSERVER__EXPOSE_CONFIG: "true"
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
- git_sync
|
||||||
|
|
||||||
|
# Mount ONLY the folder where your DAGs are inside the git repo
|
||||||
volumes:
|
volumes:
|
||||||
- ./airflow/dags:/opt/airflow/dags
|
- airflow_git:/opt/airflow/gitrepo
|
||||||
- ./airflow/logs:/opt/airflow/logs
|
- airflow_logs:/opt/airflow/logs
|
||||||
- ./airflow/plugins:/opt/airflow/plugins
|
- airflow_plugins:/opt/airflow/plugins
|
||||||
|
|
||||||
|
# We symlink your DAG directory inside entrypoint
|
||||||
command: >
|
command: >
|
||||||
bash -c "airflow db migrate && airflow scheduler & exec airflow webserver"
|
bash -c "
|
||||||
|
airflow db migrate &&
|
||||||
|
mkdir -p /opt/airflow/dags &&
|
||||||
|
ln -s /opt/airflow/gitrepo/repo/airflow/airflow/dags/* /opt/airflow/dags/ &&
|
||||||
|
airflow scheduler &
|
||||||
|
exec airflow webserver
|
||||||
|
"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
airflow_git:
|
||||||
airflow_logs:
|
airflow_logs:
|
||||||
airflow_plugins:
|
airflow_plugins:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue