From ff1c099de24237e58ed7931acf3e2f3f40b7adcc Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 2 Aug 2021 17:20:27 +0300 Subject: docker: fix CMD handling It was difficult to override CMD (due to the requirement to `activate` the venv), move the `activate` call to entrypoint.sh. --- Dockerfile | 2 +- docker/entrypoint.sh | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index b722ec7..55e24ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,4 +19,4 @@ COPY ["cgitize/", "/usr/src/cgitize/"] WORKDIR /usr/src ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"] -CMD . /tmp/venv/bin/activate && python3 -m cgitize.main +CMD python3 -m cgitize.main diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index cf6eb77..5a07263 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -10,7 +10,10 @@ set -o errexit -o nounset -o pipefail schedule="${SCHEDULE:-once}" case "$schedule" in - once) exec "$@" ;; + once) + . /tmp/venv/bin/activate + exec "$@" + ;; 15min) schedule='*/15 * * * *' ;; hourly) schedule='0 * * * *' ;; daily) schedule='0 0 * * *' ;; @@ -20,7 +23,7 @@ case "$schedule" in esac script="#!/bin/bash -cd /usr/src &&$( printf -- ' %q' "$@" )" +cd /usr/src && . /tmp/venv/bin/activate &&$( printf -- ' %q' "$@" )" echo "$script" > /task.sh chmod +x /task.sh -- cgit v1.2.3