# Build arg lets docker-compose pick the Airflow 2 or 3 base image.
ARG AIRFLOW_BASE_IMAGE=apache/airflow:2.10.4
FROM ${AIRFLOW_BASE_IMAGE}

# Copy the airflow-mcd source from the repo root (build context = repo root).
COPY --chown=airflow:root . /opt/airflow-mcd/

# Install airflow-mcd in editable mode so the local source is used.
# Use --no-deps to avoid downgrading any Airflow provider already in the image.
# .dockerignore excludes .git so setuptools-scm cannot detect the version;
# pretend version 0.0.0 for the e2e test image.
RUN SETUPTOOLS_SCM_PRETEND_VERSION_FOR_AIRFLOW_MCD=0.0.0 \
    pip install --no-cache-dir --no-deps -e /opt/airflow-mcd/

# Install runtime dependencies explicitly (pycarlo, packaging, dataclasses_json).
RUN pip install --no-cache-dir \
    "pycarlo>=0.10.5" \
    "packaging>=21" \
    "dataclasses-json"

COPY --chown=airflow:root scripts/e2e/entrypoint.sh /entrypoint-mcd.sh
RUN chmod +x /entrypoint-mcd.sh

ENTRYPOINT ["/bin/bash", "/entrypoint-mcd.sh"]
