Skip to content

Mise & runtime secrets setup - #105

Draft
DarkoKukovec wants to merge 9 commits into
mainfrom
feature/setup-mise
Draft

Mise & runtime secrets setup#105
DarkoKukovec wants to merge 9 commits into
mainfrom
feature/setup-mise

Conversation

@DarkoKukovec

@DarkoKukovec DarkoKukovec commented Apr 16, 2026

Copy link
Copy Markdown
Member

No description provided.

@github-actions

github-actions Bot commented Apr 16, 2026

Copy link
Copy Markdown

Coverage diff

Metric PR main Δ
Statements 27.89% N/A N/A
Branches 44.07% N/A N/A
Functions 46.03% N/A N/A
Lines 26.58% N/A N/A

Base coverage artifact missing; only PR coverage is shown.

🧮 Per-package delta
Package Metric PR main Δ
frontend Statements 20.09% N/A N/A
Branches 35.41% N/A N/A
Functions 21.62% N/A N/A
Lines 20.09% N/A N/A
ui Statements 80.00% N/A N/A
Branches 81.81% N/A N/A
Functions 80.76% N/A N/A
Lines 82.47% N/A N/A

@DarkoKukovec DarkoKukovec changed the title Mise setup Runtime secrets setup May 12, 2026
@DarkoKukovec DarkoKukovec changed the title Runtime secrets setup Mise & runtime secrets setup May 12, 2026
Comment thread apps/frontend/Dockerfile
# bash is needed by the wrapper shims under ./scripts (with-mise.sh,
# with-secrets.sh) that root + per-app pnpm scripts route through.
# Alpine ships only busybox sh, which lacks the bashisms ([[ ]], arrays).
RUN apk add --no-cache bash && corepack enable

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is worth doing or there is a better way...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we completely get rid of corepack already and switch to mise in CI/CD also?

https://mise.jdx.dev/continuous-integration.html#github-actions

Comment thread apps/frontend/Dockerfile
Comment thread apps/frontend/package.json

When multiple apps each declare their own secrets, the driver layers them so the host process has all secrets in env by the time `docker compose up` runs. **Compose's `environment:` block is what enforces isolation between services** — each service forwards only the names it lists. So even though the host process briefly holds both frontend's and backend's secrets, the frontend container only sees `NEXTAUTH_SECRET`, the backend container only sees `DATABASE_PASSWORD`, and storybook sees nothing.

A subtle footgun worth knowing about: **don't share secret *names* between apps.** If `apps/frontend/.env.secret` and `apps/backend/.env.secret` both declare `API_KEY`, the layer that runs last wins for that name in the host process — and both services' `environment: - API_KEY` blocks will receive the same value. Use app-scoped names (`FRONTEND_API_KEY`, `BACKEND_API_KEY`) so each app's secret namespace stays disjoint.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this might need more highlighting, maybe even runtime warnings?


## Daily usage

Day-to-day, just use the pnpm scripts. The root scripts route through [scripts/with-mise.sh](../scripts/with-mise.sh) — a tiny shim that prefixes `mise exec --` when mise is on PATH, so the pinned toolchain is used even from a shell that hasn't been activated:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is overkill...

Comment thread scripts/with-secrets.sh
- **`*.local` files** — Developer-specific overrides and secrets, never committed to git.
- **`.env`** — Committed, non-secret host defaults for running the app on your local machine.
- **`.env.compose`** — Committed, non-secret Docker defaults for running the app in containers.
- **`.env.secret`** — Committed, but contains only **references** (e.g. `op://vault/item/field`), not resolved values. Read at task-run time by [scripts/with-secrets.sh](../scripts/with-secrets.sh).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need .env.secrets.local? Would be useful for switcing between envs?

- `.env.production.local`
- `.env.test.local`
- `.env.compose.local`
- `.env.secret.local` (if anyone uses `op inject` to materialize resolved values locally)

@DarkoKukovec DarkoKukovec May 12, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure if this works already... Maybe a better approach would be .env.secret.acpt, and then control with an env variable flag? e.g. pnpm dev -- acpt or something


### What if I don't have vault access yet?

If you're onboarding and don't yet have access to the project's 1Password vault (or equivalent), ask in the team channel to be added. As a short-term workaround you can export the required secrets manually in your shell before running `pnpm dev` — the wrapper's `none` fallback will pass them through if no provider is configured, or you can force it with `SECRETS_PROVIDER=none pnpm dev`. This is a stopgap — the wrapper + vault flow is the supported path.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should mention the workaround...

Comment thread scripts/with-secrets.sh

@kamdubiel kamdubiel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only read the code without docs

Comment thread apps/frontend/.gitignore
!.env.compose
# Provider-reference manifest for scripts/with-secrets.sh — pointers only,
# never resolved values. See documentation/Environment variables.md.
!.env.secret

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see reason to do another type of env file.

.env and .env.compose should be templates (no commented out lines like you did), so they should even contain the secrets env, but with "REPLACE_ME" or "SECRET" values. On localhost you very often don't even need to use those secrets for 3rd party SaaS, and if you do, you can point your scripts to .env.local and .env.compose.local that are generated automatically on postinstall, are not commited, and can serve as the containers for the secret variables if needed

Comment thread apps/frontend/Dockerfile
# bash is needed by the wrapper shims under ./scripts (with-mise.sh,
# with-secrets.sh) that root + per-app pnpm scripts route through.
# Alpine ships only busybox sh, which lacks the bashisms ([[ ]], arrays).
RUN apk add --no-cache bash && corepack enable

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we completely get rid of corepack already and switch to mise in CI/CD also?

https://mise.jdx.dev/continuous-integration.html#github-actions

Comment thread apps/frontend/Dockerfile
Comment thread apps/frontend/package.json
Comment thread apps/storybook/Dockerfile
@@ -1,8 +1,11 @@
FROM node:24.11.0-alpine AS base
FROM node:24.15.0-alpine AS base

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're already having fun, make it 26.1.0 and get rid of corepack

Comment thread scripts/with-secrets.sh
Comment thread mise.toml

[tools]
node = "24.15.0"
pnpm = "10.33.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this for the crazy vibecoders, just in case:

python = "3.14.3"
jq = "1.8.1"
yq = "4.52.4"
rg = "15.1.0"
fd = "10.4.2"

Comment thread package.json
"engines": {
"node": "24.11.0"
"node": "24.15.0",
"pnpm": "10.33.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version 11 :)

Comment thread pnpm-workspace.yaml

allowBuilds:
sharp@0.34.5: true
core-js: false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No global allow please just in case core-js maintainer will have another meltdown over night

Comment thread README.md

- **`.env.local`**: Local development overrides
- **`.env.compose`**: Docker Compose environment
- **`.env.local`**: Local development overrides (non-secret)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote - can have secrets but without values. Should serve as templates with all possible env variables

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.

2 participants