mirror of
https://github.com/velocitatem/PHANTOM.git
synced 2026-05-31 08:33:36 +00:00
chore: rewriting airflow for railway
This commit is contained in:
@@ -103,12 +103,6 @@ services:
|
|||||||
- _AIRFLOW_WWW_USER_PASSWORD=admin
|
- _AIRFLOW_WWW_USER_PASSWORD=admin
|
||||||
- REDIS_HOST=redis
|
- REDIS_HOST=redis
|
||||||
- REDIS_PORT=6379
|
- REDIS_PORT=6379
|
||||||
volumes:
|
|
||||||
- ./experiments/airflow/dags:/opt/airflow/dags
|
|
||||||
- ./experiments/airflow/logs:/opt/airflow/logs
|
|
||||||
- ./experiments/airflow/plugins:/opt/airflow/plugins
|
|
||||||
- ./experiments/procesing:/opt/airflow/procesing
|
|
||||||
- ./lib:/opt/airflow/lib
|
|
||||||
command: version
|
command: version
|
||||||
restart: "no"
|
restart: "no"
|
||||||
|
|
||||||
@@ -138,12 +132,6 @@ services:
|
|||||||
- REDIS_PORT=6379
|
- REDIS_PORT=6379
|
||||||
ports:
|
ports:
|
||||||
- "${AIRFLOW_WEBSERVER_PORT:-8085}:8080"
|
- "${AIRFLOW_WEBSERVER_PORT:-8085}:8080"
|
||||||
volumes:
|
|
||||||
- ./experiments/airflow/dags:/opt/airflow/dags:ro
|
|
||||||
- ./experiments/airflow/logs:/opt/airflow/logs
|
|
||||||
- ./experiments/airflow/plugins:/opt/airflow/plugins:ro
|
|
||||||
- ./experiments/procesing:/opt/airflow/procesing:ro
|
|
||||||
- ./lib:/opt/airflow/lib:ro
|
|
||||||
command: webserver
|
command: webserver
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
@@ -177,12 +165,6 @@ services:
|
|||||||
- NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY}
|
- NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY}
|
||||||
- REDIS_HOST=redis
|
- REDIS_HOST=redis
|
||||||
- REDIS_PORT=6379
|
- REDIS_PORT=6379
|
||||||
volumes:
|
|
||||||
- ./experiments/airflow/dags:/opt/airflow/dags:ro
|
|
||||||
- ./experiments/airflow/logs:/opt/airflow/logs
|
|
||||||
- ./experiments/airflow/plugins:/opt/airflow/plugins:ro
|
|
||||||
- ./experiments/procesing:/opt/airflow/procesing:ro
|
|
||||||
- ./lib:/opt/airflow/lib:ro
|
|
||||||
command: scheduler
|
command: scheduler
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|||||||
@@ -21,3 +21,10 @@ RUN pip install --no-cache-dir \
|
|||||||
|
|
||||||
# set airflow home
|
# set airflow home
|
||||||
ENV AIRFLOW_HOME=/opt/airflow
|
ENV AIRFLOW_HOME=/opt/airflow
|
||||||
|
|
||||||
|
COPY --chown=airflow:root experiments/airflow/dags ${AIRFLOW_HOME}/dags
|
||||||
|
COPY --chown=airflow:root experiments/procesing ${AIRFLOW_HOME}/procesing
|
||||||
|
COPY --chown=airflow:root lib ${AIRFLOW_HOME}/lib
|
||||||
|
|
||||||
|
# create logs and plugins dirs (airflow expects them)
|
||||||
|
RUN mkdir -p ${AIRFLOW_HOME}/logs ${AIRFLOW_HOME}/plugins
|
||||||
|
|||||||
41
docker/Airflow.railway.dockerfile
Normal file
41
docker/Airflow.railway.dockerfile
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
FROM apache/airflow:2.7.3-python3.11
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
supervisor \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
USER airflow
|
||||||
|
|
||||||
|
COPY requirements.txt /tmp/requirements.txt
|
||||||
|
RUN pip install --no-cache-dir -r /tmp/requirements.txt
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir \
|
||||||
|
psycopg2-binary \
|
||||||
|
apache-airflow-providers-postgres
|
||||||
|
|
||||||
|
ENV AIRFLOW_HOME=/opt/airflow
|
||||||
|
ENV AIRFLOW__CORE__EXECUTOR=SequentialExecutor
|
||||||
|
ENV AIRFLOW__CORE__LOAD_EXAMPLES=false
|
||||||
|
ENV AIRFLOW__CORE__ENABLE_XCOM_PICKLING=true
|
||||||
|
ENV AIRFLOW__WEBSERVER__EXPOSE_CONFIG=true
|
||||||
|
|
||||||
|
# copy all code into image (standalone - no volume mounts needed)
|
||||||
|
COPY --chown=airflow:root experiments/airflow/dags ${AIRFLOW_HOME}/dags
|
||||||
|
COPY --chown=airflow:root experiments/procesing ${AIRFLOW_HOME}/procesing
|
||||||
|
COPY --chown=airflow:root lib ${AIRFLOW_HOME}/lib
|
||||||
|
|
||||||
|
RUN mkdir -p ${AIRFLOW_HOME}/logs ${AIRFLOW_HOME}/plugins
|
||||||
|
|
||||||
|
# copy entrypoint script
|
||||||
|
COPY --chown=airflow:root docker/airflow-railway-entrypoint.sh /entrypoint.sh
|
||||||
|
USER root
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
USER airflow
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
20
docker/airflow-railway-entrypoint.sh
Normal file
20
docker/airflow-railway-entrypoint.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# init db and create admin user on first run
|
||||||
|
airflow db migrate
|
||||||
|
|
||||||
|
# create admin user if not exists
|
||||||
|
airflow users create \
|
||||||
|
--username "${AIRFLOW_ADMIN_USER:-admin}" \
|
||||||
|
--password "${AIRFLOW_ADMIN_PASSWORD:-admin}" \
|
||||||
|
--firstname Admin \
|
||||||
|
--lastname User \
|
||||||
|
--role Admin \
|
||||||
|
--email admin@example.com || true
|
||||||
|
|
||||||
|
# start scheduler in background
|
||||||
|
airflow scheduler &
|
||||||
|
|
||||||
|
# start webserver in foreground (Railway needs one foreground process)
|
||||||
|
exec airflow webserver --port ${PORT:-8080}
|
||||||
Reference in New Issue
Block a user