-
Notifications
You must be signed in to change notification settings - Fork 2
Mise & runtime secrets setup #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
611d263
8e11861
20aa2ed
98bec1c
8fad82a
6073825
1863922
97a9c73
bbefeec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| # NextAuth config | ||
| NEXTAUTH_SECRET="aVlrr1mODOkPGrXTt6vN515S8Cry5fnpX5pYFoM/bws=" | ||
| # NEXTAUTH_SECRET handled through .env.secret + scripts/with-secrets.sh (see documentation/Environment variables.md) | ||
| NEXTAUTH_URL="http://localhost:3000" | ||
|
|
||
| # API | ||
| API_BASE_URL="http://localhost:3000/api" | ||
|
|
||
| # Common | ||
| NODE_ENV="development" | ||
|
|
||
| # TEST_SECRET handled through .env.secret + scripts/with-secrets.sh (see documentation/Environment variables.md) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Secret references for this app. Resolved at task-run time by | ||
| # scripts/with-secrets.sh (which delegates to the configured provider CLI — | ||
| # 1Password by default, see documentation/Environment variables.md). | ||
| # | ||
| # The values here are POINTERS, not secrets. Reading this file does nothing | ||
| # without an authenticated session to the underlying secret store. | ||
| # | ||
| # Format: KEY=<provider-reference> | ||
| # 1Password: op://<vault>/<item>/<field> | ||
|
|
||
| NEXTAUTH_SECRET=op://JS general/ReactExample/NextAuthSecret | ||
| TEST_SECRET=op://JS general/ReactExample/TestSecret |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,6 @@ src/lib/i18n/locales/en/*.d.json.ts | |
| .env* | ||
| !.env | ||
| !.env.compose | ||
| # Provider-reference manifest for scripts/with-secrets.sh — pointers only, | ||
| # never resolved values. See documentation/Environment variables.md. | ||
| !.env.secret | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| FROM node:24.11.0-alpine AS base | ||
| FROM node:24.15.0-alpine AS base | ||
| WORKDIR /app | ||
| ENV PNPM_HOME="/pnpm" | ||
| ENV PATH="$PNPM_HOME:$PATH" | ||
| RUN corepack enable | ||
| # 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 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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...
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| # # # TURBO PRUNE | ||
| FROM base AS turbo | ||
|
|
@@ -21,6 +24,12 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | |
| FROM dependencies AS development | ||
|
|
||
| COPY --from=turbo /app/out/full ./ | ||
| # Root `pnpm build` and the app's own `pnpm dev`/`pnpm build` route through | ||
| # ./scripts/with-mise.sh and ./scripts/with-secrets.sh respectively; | ||
| # scripts/ isn't part of `turbo prune --docker` output, so copy it | ||
| # explicitly. Both wrappers fall through to plain `exec` inside the | ||
| # container (no mise/op CLI to delegate to). | ||
| COPY scripts ./scripts | ||
|
|
||
| EXPOSE 3000 | ||
|
|
||
|
|
@@ -29,6 +38,17 @@ CMD ["pnpm", "dev"] | |
| # # # Builder | ||
| FROM development AS builder | ||
|
|
||
| # Secrets needed for `next build` (envsafe validates them during static | ||
| # rendering). Passed in via docker-compose `build.args` from the host's | ||
| # env, which is populated by scripts/with-secrets.sh resolving op:// refs | ||
| # (locally) or the pipeline's env: block (CI). These ENV declarations are | ||
| # scoped to this stage — the production stage below restarts FROM base, so | ||
| # the values do not propagate into the final image. | ||
| ARG NEXTAUTH_SECRET | ||
| ARG TEST_SECRET | ||
| ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET | ||
| ENV TEST_SECRET=$TEST_SECRET | ||
|
DarkoKukovec marked this conversation as resolved.
|
||
|
|
||
| RUN pnpm build | ||
|
|
||
| # # # Production | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| import { secretEnv } from '../../../../lib/env/validate-env.server'; | ||
| import { AuthCard } from '../_components/AuthCard/AuthCard'; | ||
| import { LoginForm } from '../_components/LoginForm/LoginForm'; | ||
|
|
||
| export default function LoginPage() { | ||
| const serverVars = secretEnv(); | ||
| const secret = serverVars.TEST_SECRET; | ||
|
|
||
| return ( | ||
| <AuthCard> | ||
| <LoginForm /> | ||
| <code>{secret}</code> | ||
| </AuthCard> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| FROM node:24.11.0-alpine AS base | ||
| FROM node:24.15.0-alpine AS base | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| WORKDIR /app | ||
| ENV PNPM_HOME="/pnpm" | ||
| ENV PATH="$PNPM_HOME:$PATH" | ||
| RUN corepack enable | ||
| # 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 | ||
|
|
||
| # # # TURBO PRUNE | ||
| FROM base AS turbo | ||
|
|
@@ -22,6 +25,10 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile | |
| FROM dependencies AS builder | ||
|
|
||
| COPY --from=turbo /app/out/full ./ | ||
| # Root `pnpm build` runs ./scripts/with-mise.sh; scripts/ isn't part of | ||
| # `turbo prune --docker` output, so copy it explicitly. The wrapper falls | ||
| # through to plain `exec` inside the container (no mise to delegate to). | ||
| COPY scripts ./scripts | ||
|
|
||
| RUN pnpm build | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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