# Airflow 2.x image with the MCA SDK + sklearn baked in.
# Use `docker compose up -d --build`; the DAG file is bind-mounted from
# the host so edits reload without rebuilding.

FROM apache/airflow:2.9.3-python3.11

WORKDIR /opt/airflow

COPY --chown=airflow:root requirements.txt /requirements.txt
RUN pip install --no-cache-dir -r /requirements.txt

# The DAG folder is mounted at runtime via docker-compose.yml, not baked
# into the image. Train the toy model at image-build time so the DAG has
# an artifact to load; replace this with your production artifact-fetch
# step (S3 / GCS / Artifact Registry) when deploying for real.
COPY --chown=airflow:root train_model.py /opt/airflow/train_model.py
RUN python /opt/airflow/train_model.py || true

# `standalone` boots scheduler+webserver+worker in one process for the
# local demo. Production deployments use the split services.
CMD ["standalone"]
