From 21e45c89b27e9525af03b8d85820b231be5876d9 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Sat, 7 Dec 2024 11:19:55 -0800 Subject: [PATCH] fixed env vars --- apps/backend/.env | 18 +++++++++--------- apps/backend/.env.development | 12 ++++++------ apps/backend/prisma/seed.ts | 20 ++++++++++---------- docker/server/.env | 20 ++++++++++---------- docker/server/.env.example | 16 +++++++--------- docker/server/entrypoint.sh | 5 +++++ 6 files changed, 47 insertions(+), 44 deletions(-) diff --git a/apps/backend/.env b/apps/backend/.env index a31ce6b12..d2d3715c0 100644 --- a/apps/backend/.env +++ b/apps/backend/.env @@ -4,15 +4,15 @@ NEXT_PUBLIC_STACK_DASHBOARD_URL=# the URL of Stack's dashboard. For local develo STACK_SERVER_SECRET=# a random, unguessable secret key generated by `pnpm generate-keys` # seed script settings -STACK_SEED_SIGN_UP_ENABLED=# true to add OTP auth to the dashboard when seeding -STACK_SEED_OTP_ENABLED=# true to add OTP auth to the dashboard when seeding -STACK_SEED_ALLOW_LOCALHOST=# true to allow running dashboard on the localhost, set this to true only in development -STACK_SEED_OAUTH_PROVIDERS=# list of oauth providers to add to the dashboard when seeding, separated by comma, for example "github,google,facebook" -STACK_SEED_CLIENT_TEAM_CREATION=# true to allow the users of the internal project to create teams -STACK_SEED_USER_EMAIL=# default user added to the dashboard -STACK_SEED_USER_PASSWORD=# default user's password, paired with STACK_SEED_USER_EMAIL -STACK_SEED_USER_INTERNAL_ACCESS=# if the default user has access to the internal dashboard project -STACK_SEED_USER_GITHUB_ID=# add github oauth id to the default user +STACK_SEED_INTERNAL_PROJECT_SIGN_UP_ENABLED=# true to add OTP auth to the dashboard when seeding +STACK_SEED_INTERNAL_PROJECT_OTP_ENABLED=# true to add OTP auth to the dashboard when seeding +STACK_SEED_INTERNAL_PROJECT_ALLOW_LOCALHOST=# true to allow running dashboard on the localhost, set this to true only in development +STACK_SEED_INTERNAL_PROJECT_OAUTH_PROVIDERS=# list of oauth providers to add to the dashboard when seeding, separated by comma, for example "github,google,facebook" +STACK_SEED_INTERNAL_PROJECT_CLIENT_TEAM_CREATION=# true to allow the users of the internal project to create teams +STACK_SEED_INTERNAL_PROJECT_USER_EMAIL=# default user added to the dashboard +STACK_SEED_INTERNAL_PROJECT_USER_PASSWORD=# default user's password, paired with STACK_SEED_INTERNAL_PROJECT_USER_EMAIL +STACK_SEED_INTERNAL_PROJECT_USER_INTERNAL_ACCESS=# if the default user has access to the internal dashboard project +STACK_SEED_INTERNAL_PROJECT_USER_GITHUB_ID=# add github oauth id to the default user STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=# default publishable client key for the internal project STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=# default secret server key for the internal project STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=# default super secret admin key for the internal project diff --git a/apps/backend/.env.development b/apps/backend/.env.development index 36279b37f..da05864c6 100644 --- a/apps/backend/.env.development +++ b/apps/backend/.env.development @@ -2,12 +2,12 @@ NEXT_PUBLIC_STACK_API_URL=http://localhost:8102 NEXT_PUBLIC_STACK_DASHBOARD_URL=http://localhost:8101 STACK_SERVER_SECRET=23-wuNpik0gIW4mruTz25rbIvhuuvZFrLOLtL7J4tyo -STACK_SEED_SIGN_UP_ENABLED=true -STACK_SEED_OTP_ENABLED=true -STACK_SEED_ALLOW_LOCALHOST=true -STACK_SEED_OAUTH_PROVIDERS=github,spotify,google,microsoft -STACK_SEED_CLIENT_TEAM_CREATION=true -STACK_SEED_USER_INTERNAL_ACCESS=true +STACK_SEED_INTERNAL_PROJECT_SIGN_UP_ENABLED=true +STACK_SEED_INTERNAL_PROJECT_OTP_ENABLED=true +STACK_SEED_INTERNAL_PROJECT_ALLOW_LOCALHOST=true +STACK_SEED_INTERNAL_PROJECT_OAUTH_PROVIDERS=github,spotify,google,microsoft +STACK_SEED_INTERNAL_PROJECT_CLIENT_TEAM_CREATION=true +STACK_SEED_INTERNAL_PROJECT_USER_INTERNAL_ACCESS=true STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=this-super-secret-admin-key-is-for-local-development-only diff --git a/apps/backend/prisma/seed.ts b/apps/backend/prisma/seed.ts index 6146643a6..4bb04b2bd 100644 --- a/apps/backend/prisma/seed.ts +++ b/apps/backend/prisma/seed.ts @@ -9,18 +9,18 @@ async function seed() { console.log('Seeding database...'); // Optional default admin user - const adminEmail = process.env.STACK_SEED_USER_EMAIL; - const adminPassword = process.env.STACK_SEED_USER_PASSWORD; - const adminInternalAccess = process.env.STACK_SEED_USER_INTERNAL_ACCESS === 'true'; - const adminGithubId = process.env.STACK_SEED_USER_GITHUB_ID; + const adminEmail = process.env.STACK_SEED_INTERNAL_PROJECT_USER_EMAIL; + const adminPassword = process.env.STACK_SEED_INTERNAL_PROJECT_USER_PASSWORD; + const adminInternalAccess = process.env.STACK_SEED_INTERNAL_PROJECT_USER_INTERNAL_ACCESS === 'true'; + const adminGithubId = process.env.STACK_SEED_INTERNAL_PROJECT_USER_GITHUB_ID; // dashboard settings const dashboardDomain = process.env.NEXT_PUBLIC_STACK_DASHBOARD_URL; - const oauthProviderIds = process.env.STACK_SEED_OAUTH_PROVIDERS?.split(',') ?? []; - const otpEnabled = process.env.STACK_SEED_OTP_ENABLED === 'true'; - const signUpEnabled = process.env.STACK_SEED_SIGN_UP_ENABLED === 'true'; - const allowLocalhost = process.env.STACK_SEED_ALLOW_LOCALHOST === 'true'; - const clientTeamCreation = process.env.STACK_SEED_CLIENT_TEAM_CREATION === 'true'; + const oauthProviderIds = process.env.STACK_SEED_INTERNAL_PROJECT_OAUTH_PROVIDERS?.split(',') ?? []; + const otpEnabled = process.env.STACK_SEED_INTERNAL_PROJECT_OTP_ENABLED === 'true'; + const signUpEnabled = process.env.STACK_SEED_INTERNAL_PROJECT_SIGN_UP_ENABLED === 'true'; + const allowLocalhost = process.env.STACK_SEED_INTERNAL_PROJECT_ALLOW_LOCALHOST === 'true'; + const clientTeamCreation = process.env.STACK_SEED_INTERNAL_PROJECT_CLIENT_TEAM_CREATION === 'true'; let internalProject = await prisma.project.findUnique({ where: { @@ -253,7 +253,7 @@ async function seed() { } }); } else if (!allowLocalhost) { - throw new Error('Cannot use localhost as a trusted domain if STACK_SEED_ALLOW_LOCALHOST is not set to true'); + throw new Error('Cannot use localhost as a trusted domain if STACK_SEED_INTERNAL_PROJECT_ALLOW_LOCALHOST is not set to true'); } } diff --git a/docker/server/.env b/docker/server/.env index 1993736d1..3b28d2230 100644 --- a/docker/server/.env +++ b/docker/server/.env @@ -1,6 +1,6 @@ NEXT_PUBLIC_STACK_API_URL=# https://your-backend-domain.com NEXT_PUBLIC_STACK_DASHBOARD_URL=# https://your-dashboard-domain.com, this will be added as a trusted domain by the seed script -STACK_SEED_ALLOW_LOCALHOST=# if true, the internal dashboard project will allow localhost as a trusted domain. Do not set this to true in production. +STACK_SEED_INTERNAL_PROJECT_ALLOW_LOCALHOST=# if true, the internal dashboard project will allow localhost as a trusted domain. Do not set this to true in production. STACK_DATABASE_CONNECTION_STRING=# postgres connection string with pooler STACK_DIRECT_DATABASE_CONNECTION_STRING=# postgres direct connection string @@ -11,15 +11,15 @@ STACK_SECRET_SERVER_KEY=# a secure random string STACK_SERVER_SECRET=# a 32 bytes base64url encoded random string, used for JWT encryption. can be generated with `pnpm generate-keys` # seed script settings -STACK_SEED_SIGN_UP_ENABLED=# true to add OTP auth to the dashboard when seeding -STACK_SEED_OTP_ENABLED=# true to add OTP auth to the dashboard when seeding -STACK_SEED_ALLOW_LOCALHOST=# true to allow running dashboard on the localhost, set this to true only in development -STACK_SEED_OAUTH_PROVIDERS=# list of oauth providers to add to the dashboard when seeding, separated by comma, for example "github,google,facebook" -STACK_SEED_CLIENT_TEAM_CREATION=# true to allow the users of the internal project to create teams -STACK_SEED_USER_EMAIL=# default user added to the dashboard -STACK_SEED_USER_PASSWORD=# default user's password, paired with STACK_SEED_USER_EMAIL -STACK_SEED_USER_INTERNAL_ACCESS=# if the default user has access to the internal dashboard project -STACK_SEED_USER_GITHUB_ID=# add github oauth id to the default user +STACK_SEED_INTERNAL_PROJECT_SIGN_UP_ENABLED=# true to add OTP auth to the dashboard when seeding +STACK_SEED_INTERNAL_PROJECT_OTP_ENABLED=# true to add OTP auth to the dashboard when seeding +STACK_SEED_INTERNAL_PROJECT_ALLOW_LOCALHOST=# true to allow running dashboard on the localhost, set this to true only in development +STACK_SEED_INTERNAL_PROJECT_OAUTH_PROVIDERS=# list of oauth providers to add to the dashboard when seeding, separated by comma, for example "github,google,facebook" +STACK_SEED_INTERNAL_PROJECT_CLIENT_TEAM_CREATION=# true to allow the users of the internal project to create teams +STACK_SEED_INTERNAL_PROJECT_USER_EMAIL=# default user added to the dashboard +STACK_SEED_INTERNAL_PROJECT_USER_PASSWORD=# default user's password, paired with STACK_SEED_INTERNAL_PROJECT_USER_EMAIL +STACK_SEED_INTERNAL_PROJECT_USER_INTERNAL_ACCESS=# if the default user has access to the internal dashboard project +STACK_SEED_INTERNAL_PROJECT_USER_GITHUB_ID=# add github oauth id to the default user # Set these if you want to use any email functionality STACK_EMAIL_HOST= diff --git a/docker/server/.env.example b/docker/server/.env.example index 259d73923..27c5b902a 100644 --- a/docker/server/.env.example +++ b/docker/server/.env.example @@ -4,15 +4,13 @@ NEXT_PUBLIC_STACK_DASHBOARD_URL=http://localhost:8101 STACK_DATABASE_CONNECTION_STRING=postgres://postgres:password@host.docker.internal:5432/stackframe STACK_DIRECT_DATABASE_CONNECTION_STRING=postgres://postgres:password@host.docker.internal:5432/stackframe -NEXT_PUBLIC_STACK_PROJECT_ID=internal -NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only -STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only -STACK_SERVER_SECRET=23-wuNpik0gIW4mruTz25rbIvhuuvZFrLOLtL7J4tyo - -STACK_SEED_ALLOW_LOCALHOST=true -STACK_SEED_USER_EMAIL=admin@email.com -STACK_SEED_USER_PASSWORD=password -STACK_SEED_USER_INTERNAL_ACCESS=false +STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only +STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only +STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=23-wuNpik0gIW4mruTz25rbIvhuuvZFrLOLtL7J4tyo +STACK_SEED_INTERNAL_PROJECT_ALLOW_LOCALHOST=true +STACK_SEED_INTERNAL_PROJECT_USER_EMAIL=admin@email.com +STACK_SEED_INTERNAL_PROJECT_USER_PASSWORD=password +STACK_SEED_INTERNAL_PROJECT_USER_INTERNAL_ACCESS=false STACK_RUN_MIGRATIONS=true STACK_RUN_SEED_SCRIPT=true diff --git a/docker/server/entrypoint.sh b/docker/server/entrypoint.sh index d2043d871..3c629d431 100755 --- a/docker/server/entrypoint.sh +++ b/docker/server/entrypoint.sh @@ -2,6 +2,11 @@ set -e +export NEXT_PUBLIC_STACK_PROJECT_ID=internal +export NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=${STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY} +export STACK_SECRET_SERVER_KEY=${STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY} +export STACK_SUPER_SECRET_ADMIN_KEY=${STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY} + if [ "$STACK_RUN_MIGRATIONS" = "true" ]; then echo "Running migrations..." prisma migrate deploy --schema=./apps/backend/prisma/schema.prisma