From 756447e16ec5f9820730b34d3e854504b8b2c3fb Mon Sep 17 00:00:00 2001 From: RV Date: Sun, 25 Feb 2024 15:59:53 +0100 Subject: [PATCH] fix: share ENV vars between terminal and cron environment via ~/.env key/value pairs # Due to the fact that cron process doesn't access to declared ENV vars and doesn't load user profiles # The entrypoint.sh script stores ENV vars at runtime in the ~/.env file as key=value pairs # Then the cron line include some command to load these ENV vars from file before launching app.py # This mecanism allows to give access to the same ENV vars for app.py launch in terminal and launch via cron # Conflicts: # docker-env/Dockerfile --- docker-env/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-env/Dockerfile b/docker-env/Dockerfile index 94c3a474..8af4ad0d 100644 --- a/docker-env/Dockerfile +++ b/docker-env/Dockerfile @@ -48,7 +48,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install -y # The entrypoint.sh script stores ENV vars at runtime in the ~/.env file as key=value pairs # Then the cron line include some command to load these ENV vars from file before launching app.py # This mecanism allows to give access to the same ENV vars for app.py launch in terminal and launch via cron -RUN echo "*/15 * * * * root export \$(cat ~/.env | grep -v '#' | xargs);/venv/bin/python3 /source_code/app.py 2>&1 | /usr/bin/logger -t bloom" >> ./cron_scrapper +RUN echo "*/15 * * * * root export \$(cat ~/.env | grep -v "#" | xargs);/venv/bin/python3 ${APP_DIR}/app.py 2>&1 | /usr/bin/logger -t bloom" >> ./cron_scrapper RUN chmod 744 ./cron_scrapper # Move cron tab into the right directory