Skip to content

Commit

Permalink
Update Dockerfile with starting scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-kotliar committed Mar 15, 2021
1 parent fa850e1 commit ee1d455
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ WORKDIR /tmp

ENV CWL_AIRFLOW_VERSION "master"
ENV CWL_AIRFLOW_URL "https://github.com/Barski-lab/cwl-airflow"
COPY ./scripts/start_webserver.sh /usr/local/bin/start_webserver.sh
COPY ./scripts/start_scheduler.sh /usr/local/bin/start_scheduler.sh
COPY ./scripts/start_apiserver.sh /usr/local/bin/start_apiserver.sh

RUN apt-get update && \
# installing dependencies (including docker dependencies)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

echo "Set parameters from the environment variables or apply defaults"
: "${MYSQL_USER:=airflow}"
: "${MYSQL_PASSWORD:=airflow}"
: "${MYSQL_DATABASE:=airflow}"

echo "Wait until required database and tables are ready"
until mysql -h mysql -u ${MYSQL_USER} -p${MYSQL_PASSWORD} -e "select * from ${MYSQL_DATABASE}.dag_run"
do
echo "Sleep 1 sec"
sleep 1;
done

echo "Start cwl-airflow api"
cwl-airflow api "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

echo "Set parameters from the environment variables or apply defaults"
: "${MYSQL_USER:=airflow}"
: "${MYSQL_PASSWORD:=airflow}"
: "${MYSQL_DATABASE:=airflow}"

echo "Wait until required database is ready"
until mysql -h mysql -u ${MYSQL_USER} -p${MYSQL_PASSWORD} -e "USE ${MYSQL_DATABASE}"
do
echo "Sleep 1 sec"
sleep 1;
done

echo "Run initial configuration for CWL-Airflow"
cwl-airflow init --upgrade

echo "Start airflow scheduler"
airflow scheduler "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

echo "Set parameters from the environment variables or apply defaults"
: "${AIRFLOW_HOME:=airflow}"
: "${MYSQL_USER:=airflow}"
: "${MYSQL_PASSWORD:=airflow}"
: "${MYSQL_DATABASE:=airflow}"

echo "Wait until required database and tables are ready"
until mysql -h mysql -u ${MYSQL_USER} -p${MYSQL_PASSWORD} -e "select * from ${MYSQL_DATABASE}.dag_run"
do
echo "Sleep 1 sec"
sleep 1;
done

echo "Wait until required files are ready"
until [ -e ${AIRFLOW_HOME}/webserver_config.py ]
do
echo "Sleep 1 sec"
sleep 1;
done

echo "Disable authentication in Airflow UI"
sed -i'.backup' -e 's/^# AUTH_ROLE_PUBLIC.*/AUTH_ROLE_PUBLIC = "Admin"/g' ${AIRFLOW_HOME}/webserver_config.py

echo "Start airflow webserver"
airflow webserver "$@"
6 changes: 3 additions & 3 deletions packaging/docker_compose/local_executor/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ services:
privileged: true # maybe I don't actully need it here
restart: always
<<: *airflow_env_var
command: bash -c "EXIT_CODE=1 && while [ $$EXIT_CODE -ne 0 ]; do (airflow db check); EXIT_CODE=$$?; sleep 5; done && cwl-airflow init --upgrade && airflow scheduler"
command: start_scheduler.sh
depends_on:
- mysql

Expand All @@ -52,7 +52,7 @@ services:
<<: *airflow_volumes
<<: *airflow_env_var
restart: always
command: bash -c "EXIT_CODE=1 && while [ $$EXIT_CODE -ne 0 ]; do (mysql -h mysql -u ${MYSQL_USER} -p${MYSQL_PASSWORD} -e 'select * from ${MYSQL_DATABASE}.dag_run'); EXIT_CODE=$$?; sleep 5; done && airflow webserver"
command: start_webserver.sh
depends_on:
- scheduler # need to start only after cwl-airflow init was run

Expand All @@ -67,7 +67,7 @@ services:
<<: *airflow_volumes
<<: *airflow_env_var
restart: always
command: bash -c "EXIT_CODE=1 && while [ $$EXIT_CODE -ne 0 ]; do (mysql -h mysql -u ${MYSQL_USER} -p${MYSQL_PASSWORD} -e 'select * from ${MYSQL_DATABASE}.dag_run'); EXIT_CODE=$$?; sleep 5; done && cwl-airflow api --replay 60 --host 0.0.0.0"
command: start_apiserver.sh --replay 60 --host 0.0.0.0
depends_on:
- scheduler # need to start only after cwl-airflow init was run

Expand Down

0 comments on commit ee1d455

Please sign in to comment.