Skip to content

Persist added Composer packages in /data - #611

Open
murrant wants to merge 1 commit into
librenms:masterfrom
murrant:vendor-plugin-changes
Open

murrant wants to merge 1 commit into
librenms:masterfrom
murrant:vendor-plugin-changes

Conversation

@murrant

@murrant murrant commented Nov 15, 2026

Copy link
Copy Markdown
Member

Persist Composer packages added with lnms plugin:add across container replacement and image upgrades, without modifying the image or changing ownership in /opt/librenms.

Follows the suggestion in #607 (comment): only the list of added packages is persisted, and they are installed again against the image's dependencies.

How it works

  • LIBRENMS_COMPOSER_PLUGINS points LibreNMS at /data/composer/composer.plugins.json, the only persisted state.
  • lnms plugin:add / plugin:remove run against /data/composer/build, a copy of the image's packages plus the added ones.
  • At startup each container links vendor to that build, or to the image's vendor-image when nothing was added.
  • The build is recreated with lnms plugin:sync when the list, the image's composer.json / composer.lock, or the PHP version change. If that fails, LibreNMS starts with the image's packages and logs an error.
  • composer.json, composer.lock and vendor-image are root owned. composer.phar links to the image's composer so the LibreNMS composer wrapper doesn't try to download it.

Requires

lnms plugin:sync and LIBRENMS_COMPOSER_PLUGINS from librenms/librenms#21286, which is not in a release yet. Draft until the next LibreNMS release, the new CI step only passes on the master matrix entry until then.

Testing

Built with LIBRENMS_VERSION=master and ran the new CI step locally: add, rejecting an unavailable version, recreating all containers without reinstalling, reinstalling after an image change, and removal. test/services.sh passes on all four containers.

Composer prints "Ambiguous class resolution" warnings for dapphp/radius during installs, because the LibreNMS classmap names vendor/dapphp/radius directly. Both copies are the same locked version.

Keep the packages added with lnms plugin:add in
/data/composer/composer.plugins.json (LIBRENMS_COMPOSER_PLUGINS) and
install them with lnms plugin:sync next to a copy of the image's
dependencies in /data/composer/build.

Containers use that build at startup, or the image's vendor when nothing
was added. It is recreated when the list or the image's dependencies
change, and startup falls back to the image's packages if that fails.

The image's composer.json, composer.lock and vendor are root owned and
never modified, so no ownership changes are needed in /opt/librenms.
@murrant
murrant marked this pull request as ready for review November 16, 2026 16:16
@murrant
murrant requested a review from crazy-max as a code owner November 16, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant