Add support for additional compose files per stack (extra -f flags)#121
Merged
Merged
Conversation
…ata parsing; [Bug]: [error] 12159#12159: *38373 open() "/usr/local/emhttp/plugins/compose.manager/containers.cache.json" failed (2: No such file or directory) while sending to client Fixes mstrhakr#117
Until now a stack could only use its main compose file plus the override file the plugin manages. Many projects ship optional override files (for example docker-compose.gpu.yml for GPU support), but there was no way to include them, because the plugin builds the docker compose command itself and there was nowhere to add another -f file. What this adds: - A new "Additional Compose Files" section in the stack settings. It lists the compose files found in the stack's compose folder as checkboxes, so you can simply tick the ones you want. An advanced field is available for files that live somewhere else (absolute paths, one per line). - The selection is stored in a small extra_compose_files file in the stack folder (one path per line) and the files are appended as extra -f flags after the main compose file and the override file. This automatically applies to every action (up, down, update, pull, logs, autostart) because the command arguments are built in one central place. - The editor's Compose tab got a file dropdown that lists every file the stack is made of (main file, override file, additional files), so all of them can be viewed and edited directly. Safety details: - The editor can only open files that actually belong to the stack; the request is checked against the stack's own file list, so the endpoint cannot be used to read or write unrelated files. - Saved entries must be .yml/.yaml files and absolute paths must be under /mnt/ or /boot/config/. - A settings save coming from an outdated cached browser session leaves the new setting untouched instead of silently clearing it. - Entries pointing to files that no longer exist are skipped with a logged warning instead of breaking the stack. - Selecting additional files switches the stack to explicit file mode, so the selection cannot be ignored by Docker Compose default file discovery.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A lot of compose projects ship more than one compose file. A common example is a GPU override like docker-compose.gpu.yml that is meant to be started with:
docker compose -f docker-compose.yml -f docker-compose.gpu.yml up -dUntil now the plugin had no way to do this. It builds the compose command itself, and the only files it would ever pass were the main compose file and the plugin's own override file. The only workaround was adding a COMPOSE_FILE= line to a .env file by hand, which is easy to get wrong and not discoverable at all.
What this PR adds
Selecting additional files (stack settings): There is a new "Additional Compose Files" section in the stack settings. It shows the compose files found in the stack's compose folder (files matching compose.yml / compose.yaml, except the main and override files) as simple checkboxes, soo just tick the ones you want. For files that live outside the stack folder there is a collapsed "External files (advanced)" field where absolute paths can be entered, one per line.
How it is applied: The selection is stored in a small extra_compose_files file inside the stack folder (one path per line, relative paths are resolved against the compose folder). The files are appended as extra -f flags after the main compose file and the override file, so they win in case of conflicts, so basically same order as the manual docker compose command above. Since the plugin builds all command arguments in one central place, this automatically works for every action: up, down, update, pull, logs and autostart.
Viewing and editing the files (editor): The Compose tab in the editor got a small file dropdown. It lists every file the stack is actually made of (main compose file, override file and any additional files) and lets you view and edit each of them. The dropdown only appears when a stack has more than one file, so nothing changes for simple stacks. Switching files with unsaved changes asks for confirmation first.
Safety / design notes
Testing
Screenshots




