Repository navigation
Configure everything from a single sakuya.config.json - #5
Merged
Merged
Conversation
Configuration was spread across a root .env that the server never loaded (Bun reads .env from the working directory, and the server runs from apps/server), a second apps/server/.env, and constants hardcoded in vite.config.ts. Changing the server port broke the web proxy, and resource limits set in the root .env silently did nothing. sakuya.config.json at the repo root is now the only source, read by the server, its launcher and Vite alike. It is created with the defaults on first run, migrating any old .env so the port, data dir and login carry over, and is gitignored; sakuya.config.example.json is the committed reference, and a test keeps it identical to what a first run writes. A JSON schema gives editors autocomplete and per-setting docs. Bad values fail at startup naming the key instead of reverting to a default. Environment variables are no longer read outside Docker. Inside the image, SAKUYA_* variables override the file, and the image pins host, port and data dir. An old AUTH_ENABLED=true that the file doesn't agree with refuses to start rather than come up without a password. Resource limits collapse to limits.cpus and limits.memory, enforced as a hard ceiling by a launcher that wraps only the server: a systemd scope on Linux (each property probed separately, so an undelegated cpu controller doesn't cost the memory cap) and a job object on Windows. In Docker the app detects the container's CPU quota instead of it being restated. The boot log reports what is actually enforced, read back from the cgroup or job object. docker-compose.yml is now generic; machine-specific mounts, ports and limits belong in a gitignored docker-compose.override.yml.
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.
Summary
sakuya.config.jsonat the repo root is read by the server, its launcher and the Vite dev server. It is created with the defaults on first run, and gitignored.sakuya.config.example.jsonis the committed reference with every setting, and a test keeps it identical to what a first run writes. A JSON schema gives editors autocomplete and a description of each setting on hover..envsetup. The root.envwas never loaded by the server, because Bun reads.envfrom the working directory and the server runs fromapps/server. As a result, resource limits set there did nothing, and changing the port broke Vite's hardcoded proxy..env/apps/server/.env/ environment, so the port, data dir and login carry over. An oldAUTH_ENABLED=truethat the file doesn't agree with refuses to start rather than come up without a password.SAKUYA_*). The image pins host, port and data dir. Outside Docker they are ignored, and the boot log says so.limits.cpusandlimits.memory, enforced as a hard ceiling by a launcher that wraps only the server:docker-compose.ymlis generic; machine-specific mounts, ports and limits go in a gitignoreddocker-compose.override.yml.Breaking changes
.envfiles are ignored outside Docker (they are migrated once on first run).SAKUYA_JOB_CONCURRENCY,SAKUYA_FFMPEG_THREADS,SAKUYA_ONNX_THREADS,SAKUYA_SHARP_CONCURRENCYandSAKUYA_HARD_LIMIT;limits.cpusderives all of them.PORT/AUTH_ENABLED/AUTH_SECRETare nowSAKUYA_PORT/SAKUYA_AUTH_ENABLED/SAKUYA_AUTH_SECRET, andsakuya.config.jsonmust exist beforedocker compose up.Test plan
bun test --isolate: 107 pass. Includes new config-loader tests and the Windows job-object struct layout.bun run typecheck,bun run lint(no new warnings)bun devon Linux with limits set: the server runs in a systemd scope withmemory.max= 512 MiB andcpu.max= 1 CPU, Vite stays outside it, and/apiproxies through the configured portsSAKUYA_AUTH_ENABLEDoverride turns login on (401), and--cpus/--memoryare detectedapps/server/.envkeeps login enabled with the same password