Skip to content

Commit

Permalink
Connect to spark independent of the host name
Browse files Browse the repository at this point in the history
  • Loading branch information
hfxbse committed Nov 19, 2024
1 parent 1105e5e commit 1a68f32
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions airflow.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ RUN wget https://jdbc.postgresql.org/download/postgresql-42.7.4.jar -P /home/ai
RUN mv /tmp/upstream/exercises/winter_semester_2024-2025/05_airflow/plugins /home/airflow/airflow
RUN mv /tmp/upstream/exercises/winter_semester_2024-2025/05_airflow/dags /home/airflow/airflow
RUN mv /tmp/upstream/exercises/winter_semester_2024-2025/05_airflow/python /home/airflow/airflow

RUN sed -i 's/SPARK_MASTER_IP=hadoop/SPARK_MASTER_IP=$HADOOP_HOST/' /home/airflow/spark/conf/spark-env.sh
RUN sed -i 's/SPARK_LOCAL_IP="airflow"/SPARK_LOCAL_IP="localhost"/' /home/airflow/spark/conf/spark-env.sh
# Pyarrow fails to interperet placeholder, subsitute instead
RUN sed -i "34 i sed -i 's/hadoop:/$HADOOP_HOST:/g' /home/airflow/hadoop/etc/hadoop/core-site.xml" /startup.sh
RUN sed -i "34 i sed -i 's/hadoop:/$HADOOP_HOST:/g' /home/airflow/hadoop/etc/hadoop/yarn-site.xml" /startup.sh
RUN sed -i "26 i sed -i 's/hadoop:/\$HADOOP_HOST:/g' /home/airflow/hadoop/etc/hadoop/core-site.xml" /startup.sh
RUN sed -i "26 i sed -i 's/hadoop:/\$HADOOP_HOST:/g' /home/airflow/hadoop/etc/hadoop/yarn-site.xml" /startup.sh
# Setting AIRFLOW__WEBSERVER__BASE_URL did not get applied for unknown reasons, update the config file instead
RUN sed -i "34 i sed -i 's#base_url = http://localhost:8080#base_url = http://localhost:8080/airflow#' /home/airflow/airflow/airflow.cfg" /startup.sh
RUN sed -i "26 i sed -i 's#base_url = http://localhost:8080#base_url = http://localhost:8080/airflow#' /home/airflow/airflow/airflow.cfg" /startup.sh

COPY airflow/ /home/airflow/airflow/
COPY spark/ /home/airflow/airflow/python/
Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
environment:
- POSTGRES_HOST_AUTH_METHOD=trust

hadoop:
hadoop-test:
build:
dockerfile: hadoop.Dockerfile
ports:
Expand All @@ -40,5 +40,7 @@ services:
depends_on:
user-db:
condition: service_started
hadoop:
hadoop-test:
condition: service_healthy
environment:
- HADOOP_HOST=hadoop-test

0 comments on commit 1a68f32

Please sign in to comment.