From 22c012478b15767d41a150bbe7225f2c1b538760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Loipf=C3=BChrer?= Date: Thu, 4 Jan 2024 15:35:20 +0100 Subject: [PATCH] chore: improve docker entrypoint and restructure --- .github/workflows/push_on_master.yaml | 4 ++-- .gitignore | 1 + docker/Dockerfile-api | 2 +- docker/entrypoint.py | 11 +++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/push_on_master.yaml b/.github/workflows/push_on_master.yaml index 2318966a..955dd063 100644 --- a/.github/workflows/push_on_master.yaml +++ b/.github/workflows/push_on_master.yaml @@ -31,10 +31,10 @@ jobs: run: | # if we're running from a tag, get the full list of distros; otherwise just use debian:sid dists='["debian:bookworm"]' - tags="latest $GITHUB_SHA" + tags="master $GITHUB_SHA" if [[ $GITHUB_REF == refs/tags/* ]]; then dists=$(tools/build_debian_packages.py --show-dists-json) - tags="latest $GITHUB_SHA latest-release $GITHUB_REF_NAME" + tags="master $GITHUB_SHA latest latest-release $GITHUB_REF_NAME" fi echo "::set-output name=distros::$dists" echo "::set-output name=tags::$tags" diff --git a/.gitignore b/.gitignore index 29d7a114..a4a00f37 100644 --- a/.gitignore +++ b/.gitignore @@ -123,5 +123,6 @@ Sessionx.vim [._]*.un~ ### Docker ### +.env docker-compose.yaml docker-compose.yml diff --git a/docker/Dockerfile-api b/docker/Dockerfile-api index 4f379228..8a09fe39 100644 --- a/docker/Dockerfile-api +++ b/docker/Dockerfile-api @@ -12,4 +12,4 @@ ADD --chmod=644 --chown=abrechnung:abrechnung config/abrechnung.yaml /etc/abrech ADD --chmod=755 ./docker/entrypoint.py / COPY --chown=abrechnung:abrechnung ./docker/crontab /var/spool/cron/crontabs/abrechnung USER abrechnung -ENTRYPOINT ["/opt/abrechnung-venv/bin/python3", "/entrypoint.py"] \ No newline at end of file +ENTRYPOINT ["/opt/abrechnung-venv/bin/python3", "-u", "/entrypoint.py"] \ No newline at end of file diff --git a/docker/entrypoint.py b/docker/entrypoint.py index 47954135..09c51898 100644 --- a/docker/entrypoint.py +++ b/docker/entrypoint.py @@ -67,16 +67,15 @@ def to_bool(data: str): with open("/etc/abrechnung/abrechnung.yaml", "w", encoding="utf-8") as file: file.write(output) print("config done") -sys.stdout.flush() + if sys.argv[1] == "api": - print("migrating") - sys.stdout.flush() - subprocess.run([abrechnung_venv_python, "-m", "abrechnung", "db", "migrate"], shell=True, check=True) + print("migrating ...") + subprocess.run([abrechnung_venv_python, "-m", "abrechnung", "-vvv", "db", "migrate"], check=True, stdout=sys.stdout) print("migrated") + if sys.argv[1] == "cron": print("running cron...") - sys.stdout.flush() execlp("crond", "crond", "-f") + print(f"starting abrechnung with forwarded argv {sys.argv}") -sys.stdout.flush() execvp(abrechnung_venv_python, [abrechnung_venv_python, "-m", "abrechnung"] + sys.argv[1:])