Spaces:
Sleeping
Sleeping
File size: 2,862 Bytes
6973475 edc9558 6973475 edc9558 ded8838 edc9558 9c191b0 6973475 edc9558 9c191b0 6973475 edc9558 6973475 edc9558 6973475 b0bbc2c edc9558 6973475 edc9558 6973475 edc9558 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | FROM python:3.11-slim
# ββ System packages βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# libgomp1 : required by LightGBM (OpenMP runtime)
# git : required by MLflow's git-hash logging (suppressed below if absent)
RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 \
git \
&& rm -rf /var/lib/apt/lists/*
# ββ Non-root user (HuggingFace Spaces requirement) ββββββββββββββββββββββββββββ
RUN useradd -m -u 1000 user
# ββ Environment βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONUNBUFFERED=1 \
FLASK_ENV=production \
GIT_PYTHON_REFRESH=quiet \
# Apache Airflow
AIRFLOW_HOME=/home/user/airflow \
AIRFLOW__CORE__DAGS_FOLDER=/app/dags \
AIRFLOW__CORE__LOAD_EXAMPLES=False \
AIRFLOW__CORE__EXECUTOR=SequentialExecutor \
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=sqlite:////home/user/airflow/airflow.db \
AIRFLOW__SCHEDULER__DAG_DIR_LIST_INTERVAL=15 \
AIRFLOW__SCHEDULER__SCHEDULER_HEARTBEAT_SEC=1 \
AIRFLOW__SCHEDULER__MIN_FILE_PROCESS_INTERVAL=5 \
AIRFLOW__LOGGING__BASE_LOG_FOLDER=/home/user/airflow/logs \
AIRFLOW__WEBSERVER__SECRET_KEY=automlops-hf-secret \
# MLflow β absolute path so Airflow tasks (different CWD) share the same DB
MLFLOW_TRACKING_URI=sqlite:////app/mlflow.db
USER user
WORKDIR /app
# ββ Python dependencies βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Install app dependencies first (faster layer caching)
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Install Apache Airflow with its official constraint file to avoid conflicts
ARG AIRFLOW_VERSION=2.10.4
RUN pip install --no-cache-dir \
"apache-airflow==${AIRFLOW_VERSION}" \
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-3.11.txt"
# ββ Application code ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
COPY --chown=user . .
# Create directories needed at runtime and ensure start.sh is executable
RUN mkdir -p mlruns logs /home/user/airflow/logs && chmod +x /app/start.sh
# Initialise Airflow metadata DB (SQLite β no external DB needed)
RUN airflow db migrate
EXPOSE 7860
CMD ["/app/start.sh"]
|