Skip to content

Commit

Permalink
chore: improve docker entrypoint and restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
mikonse committed Jan 4, 2024
1 parent 5277382 commit 22c0124
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/push_on_master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,6 @@ Sessionx.vim
[._]*.un~

### Docker ###
.env
docker-compose.yaml
docker-compose.yml
2 changes: 1 addition & 1 deletion docker/Dockerfile-api
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
ENTRYPOINT ["/opt/abrechnung-venv/bin/python3", "-u", "/entrypoint.py"]
11 changes: 5 additions & 6 deletions docker/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:])

0 comments on commit 22c0124

Please sign in to comment.