Files
Emil BurzoandMarc 'risson' Schmitt 8c43c174fa lifecycle: rewrite the container entrypoint in Rust (#26320)
* lifecycle: rewrite the container entrypoint in Rust and add a debug image

* improvements

* rename debug-image stage to just debug

* rename final stage

Co-authored-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: Emil Burzo <[email protected]>

* message when readline is unavailable

* remove find_shell / no_shell_error

* refactor commands/arguments based on feedback

* redo

* wip

* wip

* wip

* read AUTHENTIK_DEBUGGER directly in rust instead of shelling out

---------

Signed-off-by: Emil Burzo <[email protected]>
Co-authored-by: Marc 'risson' Schmitt <[email protected]>
2026-10-14 11:43:05 +01:00

36 lines
973 B
Python
Executable File

#!/ak-root/.venv/bin/python
"""Hands every command to the authentik binary.
The container runs this file as `/lifecycle/ak`.
In a development checkout, uv installs it as a console script.
"""
import os
import shutil
import sys
# Subcommands of the authentik binary
COMMANDS = ("allinone", "server", "worker", "proxy", "healthcheck", "test-all", "debug")
# Subcommands that hand their arguments to another program
PASSTHROUGH_COMMANDS = ("manage", "dump_config", "bash", "sh")
def main():
args = sys.argv[1:]
if args and args[0] in COMMANDS:
argv = args
elif args and args[0] in PASSTHROUGH_COMMANDS:
argv = [args[0], "--", *args[1:]]
else:
argv = ["manage", "--", *args]
binary = shutil.which("authentik")
if binary:
os.execv(binary, [binary, *argv])
# A development checkout without an installed binary
os.execvp("cargo", ["cargo", "run", "--", *argv]) # nosec
if __name__ == "__main__":
main()