-
Notifications
You must be signed in to change notification settings - Fork 464
Add Varlock for managing config + secrets #1062
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
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # This env file uses @env-spec - see https://varlock.dev/env-spec for more info | ||
| # | ||
| # @defaultRequired=true @defaultSensitive=false | ||
| # @currentEnv=$NODE_ENV | ||
| # @generateTypes(lang=ts, path=types/env-vars.d.ts) | ||
| # ---------- | ||
|
|
||
| # @type=enum(development, production, test) | ||
| NODE_ENV=development | ||
| # @type=enum(development, production, test) | ||
| MODE=$NODE_ENV | ||
|
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. Moved this into the schema itself, and has a default value set, so additional |
||
|
|
||
| # @type=port | ||
| PORT=3000 | ||
|
|
||
| LITEFS_DIR="/litefs/data" | ||
| DATABASE_PATH="./prisma/data.db" | ||
| DATABASE_URL="file:./data.db?connection_limit=1" | ||
| CACHE_DATABASE_PATH="./other/cache.db" | ||
|
|
||
| # used to secure sessions | ||
| # @sensitive | ||
| # @docs(https://stack-staging.epicweb.dev/topic/deployment) | ||
| SESSION_SECRET="super-duper-s3cret" | ||
|
|
||
| # encryption seed for honeypot server | ||
| # @sensitive | ||
| # @docs(https://stack-staging.epicweb.dev/topic/deployment) | ||
| HONEYPOT_SECRET="super-duper-s3cret" | ||
|
|
||
| # this is set to a random value in the Dockerfile | ||
| # @sensitive | ||
| INTERNAL_COMMAND_TOKEN="some-made-up-token" | ||
|
|
||
| # set to false to prevent search engines from indexing the website (defaults to allow) | ||
| ALLOW_INDEXING=true | ||
|
|
||
| # enables mocks for external services | ||
| MOCKS=forEnv(development, test) | ||
|
|
||
| # will be set to curent commit sha in deployments | ||
| # @optional | ||
| COMMIT_SHA= | ||
|
|
||
| # API key for Resend (email service) | ||
| # @type=string(startsWith=re_) | ||
| # @sensitive | ||
| # @optional # remove this if using resend | ||
| # @docs(https://resend.com/docs/dashboard/api-keys/introduction#what-is-an-api-key) | ||
| RESEND_API_KEY= | ||
|
|
||
| # will be set to true when running in CI | ||
| CI=false | ||
|
|
||
| # Sentry settings (error tracking) | ||
| # note that SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_PROJECT are optional | ||
| # but enable @sentry/react-router integration and release tagging | ||
| # --- | ||
| # @type=url | ||
| # @optional # remove this if using sentry | ||
| # @example=https://examplePublicKey@o0.ingest.sentry.io/0 | ||
| # @docs(https://docs.sentry.io/concepts/key-terms/dsn-explainer/) | ||
| SENTRY_DSN= | ||
| # @optional @sensitive | ||
| SENTRY_AUTH_TOKEN= | ||
| # @required=if($SENTRY_AUTH_TOKEN) | ||
| SENTRY_ORG= | ||
| # @required=if($SENTRY_AUTH_TOKEN) | ||
| SENTRY_PROJECT= | ||
|
|
||
| # GitHub settings | ||
| # | ||
| # the mocks and some code rely on these being prefixed with "MOCK_" | ||
| # if they aren't then the real github api will be attempted | ||
| # --- | ||
| GITHUB_CLIENT_ID="MOCK_GITHUB_CLIENT_ID" | ||
| # @sensitive | ||
| GITHUB_CLIENT_SECRET="MOCK_GITHUB_CLIENT_SECRET" | ||
| # @sensitive | ||
| GITHUB_TOKEN="MOCK_GITHUB_TOKEN" | ||
| # @type=url | ||
| GITHUB_REDIRECT_URI="https://example.com/auth/github/callback" | ||
|
|
||
|
|
||
| # Tigris Object Storage (S3-compatible) Configuration | ||
| # --- | ||
| AWS_ACCESS_KEY_ID="mock-access-key" | ||
| # @sensitive | ||
| AWS_SECRET_ACCESS_KEY="mock-secret-key" | ||
| AWS_REGION="auto" | ||
| # @type=url | ||
| AWS_ENDPOINT_URL_S3="https://fly.storage.tigris.dev" | ||
| BUCKET_NAME="mock-bucket" | ||
|
|
||
| # Populated by fly.io | ||
| # --- | ||
| # current fly.io region | ||
| # @optional | ||
| FLY_REGION= | ||
| # app name as set in fly.io | ||
| # @optional | ||
| FLY_APP_NAME= | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,10 +18,9 @@ instructions: | |
|
|
||
| 1. Fork repo | ||
| 2. clone the repo | ||
| 3. Copy `.env.example` into `.env` | ||
|
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. No longer necessary. Now users only need to manage values that are different than the defaults in |
||
| 4. Run `npm install && npm run setup -s` to install dependencies and run | ||
| 3. Run `npm install && npm run setup -s` to install dependencies and run | ||
| validation | ||
| 5. Create a branch for your PR with `git checkout -b pr/your-branch-name` | ||
| 4. Create a branch for your PR with `git checkout -b pr/your-branch-name` | ||
|
|
||
| > Tip: Keep your `main` branch pointing at the original repository and make pull | ||
| > requests from branches on your fork. To do this, run: | ||
|
|
@@ -44,10 +43,10 @@ If the setup script doesn't work, you can try to run the commands manually: | |
| git clone <your-fork> | ||
| cd ./epic-stack | ||
|
|
||
| # copy the .env.example to .env | ||
| # create a file for gitignored .env overrides | ||
| # everything's mocked out during development so you shouldn't need to | ||
| # change any of these values unless you want to hit real environments. | ||
| cp .env.example .env | ||
| # set anything unless you want to hit real environments. | ||
| touch .env.local | ||
|
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. Note that |
||
|
|
||
| # Install deps | ||
| npm install | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import { | |
| useMatches, | ||
| } from 'react-router' | ||
| import { HoneypotProvider } from 'remix-utils/honeypot/react' | ||
| import { ENV } from 'varlock/env' | ||
| import { type Route } from './+types/root.ts' | ||
| import appleTouchIconAssetUrl from './assets/favicons/apple-touch-icon.png' | ||
| import faviconAssetUrl from './assets/favicons/favicon.svg' | ||
|
|
@@ -31,7 +32,6 @@ import tailwindStyleSheetUrl from './styles/tailwind.css?url' | |
| import { getUserId, logout } from './utils/auth.server.ts' | ||
| import { ClientHintCheck, getHints } from './utils/client-hints.tsx' | ||
| import { prisma } from './utils/db.server.ts' | ||
| import { getEnv } from './utils/env.server.ts' | ||
| import { pipeHeaders } from './utils/headers.server.ts' | ||
| import { honeypot } from './utils/honeypot.server.ts' | ||
| import { combineHeaders, getDomainUrl, getImgSrc } from './utils/misc.tsx' | ||
|
|
@@ -119,7 +119,6 @@ export async function loader({ request }: Route.LoaderArgs) { | |
| theme: getTheme(request), | ||
| }, | ||
| }, | ||
| ENV: getEnv(), | ||
| toast, | ||
| honeyProps, | ||
| }, | ||
|
|
@@ -138,34 +137,25 @@ function Document({ | |
| children, | ||
| nonce, | ||
| theme = 'light', | ||
| env = {}, | ||
| }: { | ||
| children: React.ReactNode | ||
| nonce: string | ||
| theme?: Theme | ||
| env?: Record<string, string | undefined> | ||
| }) { | ||
| const allowIndexing = ENV.ALLOW_INDEXING !== 'false' | ||
| return ( | ||
| <html lang="en" className={`${theme} h-full overflow-x-hidden`}> | ||
| <head> | ||
| <ClientHintCheck nonce={nonce} /> | ||
| <Meta /> | ||
| <meta charSet="utf-8" /> | ||
| <meta name="viewport" content="width=device-width,initial-scale=1" /> | ||
| {allowIndexing ? null : ( | ||
| {ENV.ALLOW_INDEXING ? null : ( | ||
| <meta name="robots" content="noindex, nofollow" /> | ||
| )} | ||
| <Links /> | ||
| </head> | ||
| <body className="bg-background text-foreground"> | ||
| {children} | ||
| <script | ||
|
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. None of this is necessary anymore. |
||
| nonce={nonce} | ||
| dangerouslySetInnerHTML={{ | ||
| __html: `window.ENV = ${JSON.stringify(env)}`, | ||
| }} | ||
| /> | ||
| <ScrollRestoration nonce={nonce} /> | ||
| <Scripts nonce={nonce} /> | ||
| </body> | ||
|
|
@@ -174,12 +164,10 @@ function Document({ | |
| } | ||
|
|
||
| export function Layout({ children }: { children: React.ReactNode }) { | ||
| // if there was an error running the loader, data could be missing | ||
| const data = useLoaderData<typeof loader | null>() | ||
| const nonce = useNonce() | ||
| const theme = useOptionalTheme() | ||
| return ( | ||
| <Document nonce={nonce} theme={theme} env={data?.ENV}> | ||
| <Document nonce={nonce} theme={theme}> | ||
| {children} | ||
| </Document> | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
This schema could be much more thorough, adding more descriptions / links, better validation logic, adding new vars to replace MODE checks.
Huge benefits, and is less overwhelming since the user only needs to set items that differ, rather than copy/pasting all items.
Also note that it is much more legible with code highlighting provided by our VSCode Plugin.
(what it looks like with syntax highlighting)
