From c5bd862ae99ea63ca0473075adb7b413deb65cb7 Mon Sep 17 00:00:00 2001 From: Evgenii Alekseev Date: Mon, 16 Oct 2023 14:32:00 +0300 Subject: [PATCH] drop includes from user home directory, introduce new variables to docker The old solution didn't actually work as expected, because devtools configuration belongs to filesystem (as well as sudo one), so it was still required to run setup command. In order to handle additional repositories, the POSTSETUP and PRESETUP commands variables have been introduced. FAQ has been updated as well --- Dockerfile | 2 ++ docker/entrypoint.sh | 3 +++ docs/configuration.rst | 2 +- docs/faq.rst | 18 +++++++++++++++++- .../ahriman/templates/build-status.jinja2 | 2 +- src/ahriman/application/handlers/setup.py | 2 +- .../core/configuration/configuration.py | 10 +++++----- tests/ahriman/conftest.py | 4 +--- .../core/configuration/test_configuration.py | 5 +---- 9 files changed, 32 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 42ee2299..3567bde6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,8 @@ ENV AHRIMAN_OUTPUT="" ENV AHRIMAN_PACKAGER="ahriman bot " ENV AHRIMAN_PACMAN_MIRROR="" ENV AHRIMAN_PORT="" +ENV AHRIMAN_POSTSETUP_COMMAND="" +ENV AHRIMAN_PRESETUP_COMMAND="" ENV AHRIMAN_REPOSITORY="aur-clone" ENV AHRIMAN_REPOSITORY_SERVER="" ENV AHRIMAN_REPOSITORY_ROOT="/var/lib/ahriman/ahriman" diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 76d10e1f..4e4446d3 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -49,7 +49,10 @@ fi if [ -n "$AHRIMAN_UNIX_SOCKET" ]; then AHRIMAN_SETUP_ARGS+=("--web-unix-socket" "$AHRIMAN_UNIX_SOCKET") fi + +[ -n "$AHRIMAN_PRESETUP_COMMAND" ] && eval "$AHRIMAN_PRESETUP_COMMAND" ahriman "${AHRIMAN_DEFAULT_ARGS[@]}" service-setup "${AHRIMAN_SETUP_ARGS[@]}" +[ -n "$AHRIMAN_POSTSETUP_COMMAND" ] && eval "$AHRIMAN_POSTSETUP_COMMAND" # validate configuration if set [ -n "$AHRIMAN_VALIDATE_CONFIGURATION" ] && ahriman "${AHRIMAN_DEFAULT_ARGS[@]}" service-config-validate --exit-code diff --git a/docs/configuration.rst b/docs/configuration.rst index 810ccf3b..9d122767 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -41,7 +41,7 @@ Base configuration settings. * ``apply_migrations`` - perform migrations on application start, boolean, optional, default ``yes``. Useful if you are using git version. Note, however, that this option must be changed only if you know what to do and going to handle migrations automatically. * ``database`` - path to SQLite database, string, required. -* ``include`` - path to directory with configuration files overrides, string, optional. Note, however, that the application will also load configuration files from the repository root, which is used, in particular, by setup subcommand. +* ``include`` - path to directory with configuration files overrides, string, optional. * ``logging`` - path to logging configuration, string, required. Check ``logging.ini`` for reference. * ``suppress_http_log_errors`` - suppress http log errors, boolean, optional, default ``no``. If set to ``yes``, any http log errors (e.g. if web server is not available, but http logging is enabled) will be suppressed. diff --git a/docs/faq.rst b/docs/faq.rst index 0ff44eb8..0ea4d305 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -402,6 +402,8 @@ The following environment variables are supported: * ``AHRIMAN_PACKAGER`` - packager name from which packages will be built, default is ``ahriman bot ``. * ``AHRIMAN_PACMAN_MIRROR`` - override pacman mirror server if set. * ``AHRIMAN_PORT`` - HTTP server port if any, default is empty. +* ``AHRIMAN_POSTSETUP_COMMAND`` - if set, the command which will be called (as root) after the setup command, but before any other actions. +* ``AHRIMAN_PRESETUP_COMMAND`` - if set, the command which will be called (as root) right before the setup command. * ``AHRIMAN_REPOSITORY`` - repository name, default is ``aur-clone``. * ``AHRIMAN_REPOSITORY_SERVER`` - optional override for the repository url. Useful if you would like to download packages from remote instead of local filesystem. * ``AHRIMAN_REPOSITORY_ROOT`` - repository root. Because of filesystem rights it is required to override default repository root. By default, it uses ``ahriman`` directory inside ahriman's home, which can be passed as mount volume. @@ -429,7 +431,7 @@ This command uses same rules as ``repo-update``, thus, e.g. requires ``--privile Web service setup ^^^^^^^^^^^^^^^^^ -Well for that you would need to have web container instance running forever; it can be achieved by the following command: +For that you would need to have web container instance running forever; it can be achieved by the following command: .. code-block:: shell @@ -451,6 +453,20 @@ Otherwise, you would need to pass ``AHRIMAN_PORT`` and mount container network t docker run --privileged --net=host -e AHRIMAN_PORT=8080 -v /path/to/local/repo:/var/lib/ahriman arcan1s/ahriman:latest +Mutli-repository web service +"""""""""""""""""""""""""""" + +Idea is pretty same as to just run web service. However, it is required to run setup commands for each repository, except for one which is specified by ``AHRIMAN_REPOSITORY`` and ``AHRIMAN_ARCHITECTURE ` variables. + +In order to create configuration for additional repositories, the ``AHRIMAN_POSTSETUP_COMMAND`` variable should be used, e.g.: + +.. code-block:: shell + + docker run --privileged -p 8080:8080 -e AHRIMAN_PORT=8080 -e AHRIMAN_UNIX_SOCKET=/var/lib/ahriman/ahriman/ahriman-web.sock -e AHRIMAN_POSTSETUP_COMMAND="ahriman --architecture x86_64 --repository aur-clone-v2 service-setup --build-as-user ahriman --packager 'ahriman bot '" -v /path/to/local/repo:/var/lib/ahriman arcan1s/ahriman:latest + +The command above will also create configuration for the repository named ``aur-clone-v2``. + +Note, however, that the command above is only required in case if the service is going to be used to run subprocesses. Otherwise, everything else (web interface, status, etc) will be handled as usual. Non-x86_64 architecture setup ----------------------------- diff --git a/package/share/ahriman/templates/build-status.jinja2 b/package/share/ahriman/templates/build-status.jinja2 index fdfc0aab..7fdf0d26 100644 --- a/package/share/ahriman/templates/build-status.jinja2 +++ b/package/share/ahriman/templates/build-status.jinja2 @@ -17,7 +17,7 @@