FROM apache/airflow:3.1.8-python3.12

ARG AIRFLOW_VERSION=3.1.8

USER root
RUN apt-get update && \
    apt-get install -y --no-install-recommends git openssl && \
    apt-get upgrade -y openssl && \
    openssl version -a && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*


COPY cheetah-airflow/${AIRFLOW_VERSION}/requirements.txt /opt/setup/requirements.txt
RUN chown -R airflow:root /opt/setup


USER airflow
WORKDIR /opt/setup
RUN pip install --no-cache-dir -r /opt/setup/requirements.txt

COPY --chown=airflow:root cheetah-airflow/${AIRFLOW_VERSION}/plugins /opt/airflow/plugins

RUN echo "Cheetah Airflow custom image build complete (Airflow ${AIRFLOW_VERSION})"
