File size: 2,011 Bytes
0383bfc
27c3627
494a23b
 
 
0383bfc
 
494a23b
 
27c3627
494a23b
0383bfc
494a23b
 
 
 
 
 
 
 
0383bfc
 
 
494a23b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d8339ba
27c3627
0383bfc
 
494a23b
0383bfc
494a23b
 
 
0383bfc
494a23b
 
 
 
 
 
0383bfc
 
27c3627
494a23b
 
 
 
051eca4
1e503b7
0383bfc
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
61
62
63
64
65
66
67
68
FROM ubuntu:22.04

LABEL maintainer="subhamgiri460"
LABEL description="Apache Airflow on HuggingFace Docker Space"

ENV DEBIAN_FRONTEND=noninteractive
ENV AIRFLOW_HOME=/opt/airflow
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# ---- System packages ----
RUN apt-get update && apt-get install -y --no-install-recommends \
        python3 \
        python3-pip \
        python3-venv \
        nginx \
        git \
        supervisor \
        curl \
        libpq-dev \
    && rm -rf /var/lib/apt/lists/* \
    && useradd -m -u 1000 airflow

# ---- Directories & permissions ----
RUN mkdir -p \
        /var/log/supervisor \
        /var/log/nginx \
        /run/nginx \
        /var/lib/nginx \
        /run/nginx/client_temp \
        /run/nginx/proxy_temp \
        /run/nginx/fastcgi_temp \
        /run/nginx/uwsgi_temp \
        /run/nginx/scgi_temp \
        /opt/airflow/dags \
        /opt/airflow/logs \
    && chown -R airflow:airflow \
        /opt/airflow \
        /var/log/supervisor \
        /var/log/nginx \
        /run/nginx \
        /var/lib/nginx

USER airflow
ENV PATH="/home/airflow/.local/bin:${PATH}"

# ---- Python dependencies (cached layer) ----
COPY --chown=airflow:airflow requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir --upgrade pip \
    && pip install --no-cache-dir -r /tmp/requirements.txt \
    && rm /tmp/requirements.txt

# ---- Application files ----
COPY --chown=airflow:airflow config.sh          /config.sh
COPY --chown=airflow:airflow supervisord.conf    /etc/supervisord.conf
COPY --chown=airflow:airflow nginx.conf          /etc/nginx/nginx.conf
COPY --chown=airflow:airflow entrypoint.sh       /entrypoint.sh
COPY --chown=airflow:airflow refresh_service.py  /refresh_service.py

RUN chmod +x /entrypoint.sh /config.sh

# ---- Health check ----
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
    CMD curl -sf http://localhost:7860/health || exit 1

EXPOSE 7860

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