forked from stevencox/roger
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
76 lines (56 loc) · 1.93 KB
/
Dockerfile
File metadata and controls
76 lines (56 loc) · 1.93 KB
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
69
70
71
72
73
74
75
76
# Use a Debian-based image for better compatibility
FROM python:3.11.14-slim-trixie
# Set Airflow version and home directory
ARG AIRFLOW_VERSION=3.1.5
ARG AIRFLOW_HOME=/opt/airflow
# Environment variables
ENV AIRFLOW_HOME=${AIRFLOW_HOME}
ENV AIRFLOW__CORE__LOAD_EXAMPLES=False
ENV AIRFLOW__CORE__EXECUTOR=LocalExecutor
ENV AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@postgres:5432/airflow
ENV PYTHONUNBUFFERED=1
# Create airflow user and directories
RUN useradd --uid 50000 --home-dir ${AIRFLOW_HOME} --create-home airflow && \
mkdir -p ${AIRFLOW_HOME}/dags ${AIRFLOW_HOME}/logs ${AIRFLOW_HOME}/plugins ${AIRFLOW_HOME}/config
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
libffi-dev \
libssl-dev \
curl \
tini \
tzdata \
git \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip tools
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Install Airflow (with PostgreSQL, Celery, Redis support)
RUN pip install --no-cache-dir \
"apache-airflow[postgres,celery,redis,fab]==${AIRFLOW_VERSION}" \
"apache-airflow-providers-cncf-kubernetes" \
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-3.11.txt"
# Optional: install extra packages
RUN pip install --no-cache-dir psycopg2-binary redis
COPY ./requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
RUN rm /tmp/requirements.txt
RUN apt-get purge -y --auto-remove \
build-essential \
libpq-dev \
libffi-dev \
libssl-dev \
curl \
git && \
apt-get clean
# Set ownership
RUN chown -R airflow:airflow ${AIRFLOW_HOME}
# Switch to airflow user
USER airflow
WORKDIR ${AIRFLOW_HOME}
# Expose Airflow webserver port
EXPOSE 8080
# Use tini for signal handling
ENTRYPOINT ["/usr/bin/tini", "--"]
# Default command
CMD ["airflow", "webserver"]