Repository navigation
Apps declare their env and secrets in morca.toml (#331) - #400
Merged
Merged
Conversation
morca-stack wrote one fixed app.env for every app: the lake, the S3 keys and the UI's PostHog key as POSTHOG_KEY. Now an app's [apps.<name>] says what it gets (port, check, env, lake, secrets, memory_gb), read from the app's own image with the new `morca config apps` (the overlay laid on it), and each app has its own env file, app-<name>.env. - Secrets: a secret's value comes from /etc/orca/secrets/<id>, never printed; SECRETS_FILE may hold any secrets/orca/<id> key, and sync takes them. A missing one stops the deploy at the plan. - APPS=console names the app; a port there is for an app with none in morca.toml, and one that differs is refused. - An undeclared app, or an image without `config apps`, keeps the old fixed env, so today's census images deploy as before. - MORCA_POSTHOG_HOST (POSTHOG_HOST in hetzner.env): where the UI's PostHog snippet goes, a proxy like /ph; PostHog's own host without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6
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.
Closes #331. Part of census#140.
Stacked on #399 (#332, overlays), which targets
main. When #399 merges, this PR moves tomain. It touches secrets handling, so it needs the user's review before merge, and auto-merge stays off.What it does
An app declares what it needs in the project's
morca.toml, the way a pipeline does.morca-stackbuilds the app's environment from that declaration instead of hardcoding it.src/morca/apps_config.mojo):[apps.<name>]is checked like every other table. Errors givefile:line, the overlay's when an overlay set the value._and-, and can't be one of the stack's own containers.envcan't setPORT, the lake's variables or anything that looks like a secret, and every value must be one line.orca/...with no..or//.morca config apps [<file>] [--overlay F]needs no database. It prints one line per fact (console port 8080,console env A=1,console secret POSTHOG_KEY orca/posthog-key), with secrets by ID only. That's what the stack script reads. With no file it prints nothing.morca-stack:planandapplyrunconfig appsin each app's own image, with the overlay mounted. They then write/etc/orca/app-<name>.env(mode 600), one file per app, holding:env;lake = true, the lake:AWS_REGION,AWS_ENDPOINT_URL_S3,MORCA_WAREHOUSE,MORCA_PUBLIC_WAREHOUSEands3.env;/etc/orca/secrets/<id>(trailing newlines dropped, more than one line refused, never printed).--memoryalso come from the declaration. The old sharedapp.envis removed after the apply.APPS=consoleinhetzner.envnames which apps a stack runs, and nothing more.console:8080still works: it gives the port to an app that has none inmorca.toml, and a port that differs from the declared one is refused.SECRETS_FILEmay now hold anysecrets/orca/<id>key, whichsync_settingssends the same way it sends the others, never printing a value.morca-stack syncaccepts these paths using the same rules assecret-fetch(no..). OnlySECRETS_FILEcarries app secrets: there's no per-file*_FILEsetting for them.morca.tomldoesn't declare, or an image whose morca has noconfig apps(exit 2, before 0.25), gets the old fixed env (the lake, plusMORCA_POSTHOG_KEYasPOSTHOG_KEY). The plan says so.MORCA_POSTHOG_HOST(POSTHOG_HOSTinhetzner.env) for where the PostHog snippet sends events. It can be a path on the UI's own origin (/ph) or anhttps://origin. When it isn't set, the snippet talks to PostHog's own US hosts (us-assets.i.posthog.com,us.i.posthog.com), since there's no proxy. Any other value leaves the snippet out.Design choices
[pipelines.<name>].envandsecretsare inline tables, secrets are IDs underorca/as for pipelines, andlakeis one boolean, not a list of variables. The stack reads the declaration throughmorca config appsfrom the image the app runs, so an app on its own tag gets its own declaration and the stack script doesn't parse TOML.morca aws'sorca-appdoesn't read[apps]yet.Census side (its own PR, after morca-mojo 0.25.0)
Add this to
morca.toml:Add
envonly if the console reads something beyond these. Nothing else changes: the console still readsPOSTHOG_KEYandPORT.ops-secrets side (in the release window, before the census image with
[apps.console])prod/secrets.sops.yaml(and dev's if dev has analytics), addsecrets/orca/posthog-key: phc_..., the same project key asPOSTHOG_KEY. Without it, a deploy of a census image that declares the secret stops at the plan.prod/hetzner.env, addPOSTHOG_HOST=/ph, or the UI's analytics go straight to PostHog instead of through the mojourney-ph Worker.APPS=console, so the port comes frommorca.toml.console:8080keeps working.Tests
Run locally on macOS:
test-config: the apps unit tests (keys, refusals, theconfig appslines, an overlay can't add an app) andtests/config.sh(config appswith and without a file, with an overlay, and its count inconfig check).test-ui: PostHog throughMORCA_POSTHOG_HOST=/ph, PostHog's own host without it, and no snippet for a bad value.tests/hetzner.sh, with only fake secret values:--memoryand mode 600, with no value printed and no database;config appsgets the fixed env;APPSport that differs is refused, andAPPS=consoleworks;SECRETS_FILE'ssecrets/orca/<id>keys are sent, and bad ones refused.tests/hetzner-stacks.sh,tests/no-orca.shandmojo format.CI runs the rest.
🤖 Generated with Claude Code
https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6