Repository navigation
Scripts: add a stack update script - #404
Closed
jackspiering wants to merge 7 commits into
Closed
jackspiering wants to merge 7 commits into
jackspiering wants to merge 7 commits into
Conversation
scripts/update-stack.sh checks stack folders that were copied out of a clone against the latest version in the repository and updates them with a three-way merge, so edits to .env and compose.yaml survive. It reads the upstream files with git only, never prints .env values, makes a backup before it writes, and never restarts containers. scripts/test-update-stack.sh tests it against a throwaway repository, and a new workflow runs ShellCheck and the test on changes to scripts/.
Download the service from GitHub instead of reading a full clone, and update compose.yaml and .env with a three-way merge against the upstream files that the last run saved in .scaletail/. This drops the base detection, the marker commit, --base, --ref and --no-fetch. - The first run replaces compose.yaml with a backup, and adds missing .env variables. - A conflict writes markers into the file, after a backup, and the next run refuses until they are resolved. - Target bash and GNU tools on Linux, not bash 3.2 and BSD.
The first update printed a unified diff of compose.yaml. Comment and context lines hid the settings that changed. Print a short overview: one line per changed setting, and a single line when only comments differ.
The overview of the first update still printed many lines for an old stack: fragments of the serve config, keys without their service, and values such as an auth key that old stacks set in compose.yaml. Print one label instead: settings differ, or only comments or spacing. After --apply, print the diff command that compares the backup with the new file. The script now prints no contents of compose.yaml or .env.
jackspiering
added a commit
to jackspiering/tailarr
that referenced
this pull request
Nov 6, 2026
* feat: keep compose edits on Apply with a 3-way merge Apply used to overwrite the deployed compose file, so an operator lost every edit. This ports the behavior of the ScaleTail stack update script (tailscale-dev/ScaleTail#404) into Tailarr. - Deploy and Apply record the catalog compose file as .tailarr.compose.base.yaml. Apply merges the catalog change into the deployed file with git merge-file, run with the hardened git setup and without user or system git config. - A conflict refuses Apply before any write and never writes conflict markers. The error says how to get past it. - A deployment without a base (older Tailarr) gets the catalog file once, and the output names the backup that holds the old file and says whether settings or only comments differed. - The base is part of the Apply snapshot, so a failed Apply rolls it back and the next Apply still sees the catalog change. - The compose file is still written in place, so its inode survives. - The preview shows the diff to the merged result, labels the file as merged, replaced, or conflict, and names .env keys the catalog dropped. - New .env keys bring the template comment lines above them. A key the operator commented out is not added again. * fix: keep adding .env keys that the catalog shipped commented out Every ScaleTail template ships optional keys as commented-out lines, so skipping a key that the deployed .env has only commented out would block the catalog from ever turning one on. Drop that rule and keep the template comments for new keys. Make the first-Apply notice and the preview note conditional on the operator having edited the file.
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.
Description
Adds
scripts/update-stack.sh. It compares a stack folder that you copied out of the clone ("Run the stack from a copy") with the latest version of the service, and updatescompose.yamland.envwithout losing your changes. It targets bash and the GNU tools on Linux.main(about 350 KB) withcurlorwget, once per run. It needs no clone, and an existing clone is not read or changed.compose.yamland.envare compared and updated.ts/, the data folders, the README, and other files stay as they are.--applysaves the upstreamcompose.yamland.envin.scaletail/. The next run merges three versions withgit merge-file: your file, that saved copy, and the new upstream file. Each file that changes is first copied to.scaletail/backup-<time>/.docker composerefuses the file too, so nothing runs half-merged..envgets the variables it lacks, with their comments.compose.yamlis replaced by the upstream version. The script says whether settings differ or only comments, keeps your old file in the backup, and prints thediffcommand that compares the two.compose.yamlor.env, only variable names. Old stacks set the auth key incompose.yaml, so a diff could show it.SERVICEchanges upstream, unless--force. Prints the## Upgradingsection of the README when there are updates.--applyit runsdocker compose config --quietwhen Docker is available, and prints only whether it passed.Also adds
scripts/test-update-stack.sh(9 cases on a fake archive served from a temporary folder, no network), thescripts.ymlworkflow (ShellCheck and the test), and docs in the rootREADME.mdandAGENTS.md.Example output, from an old Gotify copy with an edited image tag and
.env(paths shortened):Related Issues
Verification
docker compose config --quietfrom each changed service directory, with dummy values for required variables. N/A: no service changed.rumdl check --config .markdownlint.yml .on the whole repository (rumdl 0.3.0, the pinned version), andgit diff --check origin/mainshellcheck scripts/*.sh(0.10.0): no findings.bash scripts/test-update-stack.sh: all checks pass. Two deliberate breakages (no.envappend, a.envvalue in the output) make it fail, and so does the earlier overview, which printed an auth key from an oldcompose.yaml.compose.yamlis reported assettings differ, and.envgets the new variables.--applyreplacescompose.yamlwith a backup, and printsdiff .scaletail/backup-<time>/compose.yaml compose.yaml.docker compose configthen fails onrequired variable GOTIFY_DEFAULTUSER_PASS is missing, as the Upgrading section says, and the script reports the failure without quoting.env. A second run is up to date..envvalues: both files merge cleanly (output above), and the values do not appear in the output.restart:line next to the new iGotify block conflicts: the markers land incompose.yaml, the next run refuses, and after resolving it is up to date.gotifyin one run, the first with pending changes and the second up to date: the second reports up to date.--serviceworks for a folder with another name. A folder withcompose.ymlgets a hint to rename it.Impact on existing users
Checklist
Additional Context
--base,--ref,--no-fetch) with a download and a saved copy (about 270 lines). Squash-merge flattens both.git merge-fileis used instead ofdiff3 -mfrom diffutils, becausediff3 -mreports a conflict when both sides made the same change.Scripts:to the lists inAGENTS.mdandCONTRIBUTING.md.