update dag sync code

This commit is contained in:
Cameron Seamons 2025-12-10 20:53:09 -07:00
parent cb512286c1
commit 5ec0941dc7

View file

@ -12,35 +12,58 @@ services:
- postgres_data:/var/lib/postgresql/data
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:
container_name: airflow_container
image: apache/airflow:3.1.3
ports:
- ${AIRFLOW_PORT}:8080
environment:
# Database connection
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_PASSWORD: ${AIRFLOW_ADMIN_PASSWORD}
# Airflow config
AIRFLOW__CORE__LOAD_EXAMPLES: "false"
AIRFLOW__CORE__EXECUTOR: LocalExecutor
AIRFLOW__WEBSERVER__EXPOSE_CONFIG: "true"
depends_on:
- db
- git_sync
# Mount ONLY the folder where your DAGs are inside the git repo
volumes:
- ./airflow/dags:/opt/airflow/dags
- ./airflow/logs:/opt/airflow/logs
- ./airflow/plugins:/opt/airflow/plugins
- airflow_git:/opt/airflow/gitrepo
- airflow_logs:/opt/airflow/logs
- airflow_plugins:/opt/airflow/plugins
# We symlink your DAG directory inside entrypoint
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
volumes:
postgres_data:
airflow_git:
airflow_logs:
airflow_plugins: