From 6a865fea02778c873b83c0b7ec9852502d40741f Mon Sep 17 00:00:00 2001 From: amy wieliczka Date: Fri, 29 Sep 2023 15:45:17 -0700 Subject: [PATCH] Feat: enable DockerOperator usage (#4) * mount docker.sock & set perms; required for DockerOperator usage :socks: * Move docker/.env into docker/.env.example --- .gitignore | 1 + docker/{.env => .env.example} | 3 ++- docker/docker-compose-local.yml | 1 + docker/script/run-startup.sh | 6 +++++- 4 files changed, 9 insertions(+), 2 deletions(-) rename docker/{.env => .env.example} (82%) diff --git a/.gitignore b/.gitignore index 849b35b33..88ddd02f3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dags/**/*.pyc /logs /db-data .DS_Store +/docker/.env \ No newline at end of file diff --git a/docker/.env b/docker/.env.example similarity index 82% rename from docker/.env rename to docker/.env.example index adf129dc7..a6b312cf0 100644 --- a/docker/.env +++ b/docker/.env.example @@ -3,4 +3,5 @@ DAGS_HOME="" PLUGINS_HOME="" REQS_HOME="" STARTUP_HOME="" -RIKOLTI_DATA_HOME="" \ No newline at end of file +RIKOLTI_DATA_HOME="" +DOCKER_SOCKET="" \ No newline at end of file diff --git a/docker/docker-compose-local.yml b/docker/docker-compose-local.yml index 7fd1c9b36..57571939f 100644 --- a/docker/docker-compose-local.yml +++ b/docker/docker-compose-local.yml @@ -31,6 +31,7 @@ services: - "${REQS_HOME}:/usr/local/airflow/requirements" - "${STARTUP_HOME}:/usr/local/airflow/startup" - "${RIKOLTI_DATA_HOME}:/usr/local/airflow/rikolti_data" + - "${DOCKER_SOCKET}:/var/run/docker.sock" ports: - "8080:8080" command: local-runner diff --git a/docker/script/run-startup.sh b/docker/script/run-startup.sh index eb1e8013f..083dd0546 100644 --- a/docker/script/run-startup.sh +++ b/docker/script/run-startup.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash source "$AIRFLOW_HOME/startup/startup.sh" -declare -p | grep -v '^declare \-[aAilnrtux]*r ' > stored_env \ No newline at end of file +declare -p | grep -v '^declare \-[aAilnrtux]*r ' > stored_env + +# allows the airflow user on the airflow docker container to access +# the host's docker.sock. This is needed for the DockerOperator to work. +sudo chmod 666 /var/run/docker.sock \ No newline at end of file