Z
Zerops•4mo ago
arjun

ENVs are not being created

even though i've restarted after adding envs :(
No description
No description
13 Replies
arjun
arjunOP•4mo ago
i tried adding the envs in zerops yml and it worked but when i did it via dashboard it didn't work 😓
arjun
arjunOP•4mo ago
No description
Aleš
Aleš•4mo ago
have you added reference to the variable to build.envVariables ? variables are not shared by default, imagine you'd set NODE_ENV=production to env secrets and it would automatically apply to your build containers - you wouldn't be able to build your app because npm would only install production deps 🙂 you should be able to do
build:
envVariables:
DATABASE_URL: ${RUNTIME_DATABASE_URL}
build:
envVariables:
DATABASE_URL: ${RUNTIME_DATABASE_URL}
https://docs.zerops.io/features/env-variables#between-build-and-runtime-environments
arjun
arjunOP•4mo ago
🤔 okay
Aleš
Aleš•4mo ago
btw in general you shouldn't migrate inside build, but inside run.initCommands, preferably along zsc execOnce $ZEROPS_appVersionId -- prisma migrate https://docs.zerops.io/references/zsc#execonce because this way if you migrate in build and then it fails on later command, or fails to start the runtime container, or even just takes a while to finish deployment, your database might become incompatible with the API version currently running.. so doing it in init is much safer and zsc execOnce takes care of idempotency see https://github.com/fxck/shopify-app-template-remix/blob/main/zerops.yml
arjun
arjunOP•4mo ago
i've migrated to drizzle for personal reasons, will be deploying soon i'll check thanks
arjun
arjunOP•4mo ago
zerops:
- setup: app
build:
base: nodejs@22
envVariables:
DATABASE_URL: ${RUNTIME_DATABASE_URL}
buildCommands:
- pnpm i
- pnpm run build
cache:
- pnpm-lock.yaml
- node_modules
deployFiles: ./
run:
base: nodejs@22
initCommands:
- zsc execOnce $appVersionId -- drizzle-kit migrate --config=drizzle-migrate.config.ts
envVariables:
DATABASE_URL: ${db_connectionTlsString}
ports:
- port: 3000
httpSupport: true
start: pnpm start
zerops:
- setup: app
build:
base: nodejs@22
envVariables:
DATABASE_URL: ${RUNTIME_DATABASE_URL}
buildCommands:
- pnpm i
- pnpm run build
cache:
- pnpm-lock.yaml
- node_modules
deployFiles: ./
run:
base: nodejs@22
initCommands:
- zsc execOnce $appVersionId -- drizzle-kit migrate --config=drizzle-migrate.config.ts
envVariables:
DATABASE_URL: ${db_connectionTlsString}
ports:
- port: 3000
httpSupport: true
start: pnpm start
okay so i already have AUTH_RESEND_KEY in env via web but when i push it says it can't find any why so? even though i restarted the whole container before 🤔
Aleš
Aleš•4mo ago
which container is saying that?
arjun
arjunOP•4mo ago
then i copy the same env and i add them to the zerops yml (specifically build container) build container
arjun
arjunOP•4mo ago
secret variables can be accessed by both build and runtime right
No description
Aleš
Aleš•4mo ago
https://discord.com/channels/735781031147208777/1405133115411795968/1405136572533440533 👆
zerops:
- setup: app
build:
base: nodejs@22
envVariables:
DATABASE_URL: ${RUNTIME_DATABASE_URL}
AUTH_RESEND_KEY: ${RUNTIME_AUTH_RESEND_KEY}
buildCommands:
- pnpm i
- pnpm run build
cache:
- pnpm-lock.yaml
- node_modules
deployFiles: ./
run:
base: nodejs@22
initCommands:
- zsc execOnce $appVersionId -- drizzle-kit migrate --config=drizzle-migrate.config.ts
envVariables:
DATABASE_URL: ${db_connectionTlsString}
ports:
- port: 3000
httpSupport: true
start: pnpm start
zerops:
- setup: app
build:
base: nodejs@22
envVariables:
DATABASE_URL: ${RUNTIME_DATABASE_URL}
AUTH_RESEND_KEY: ${RUNTIME_AUTH_RESEND_KEY}
buildCommands:
- pnpm i
- pnpm run build
cache:
- pnpm-lock.yaml
- node_modules
deployFiles: ./
run:
base: nodejs@22
initCommands:
- zsc execOnce $appVersionId -- drizzle-kit migrate --config=drizzle-migrate.config.ts
envVariables:
DATABASE_URL: ${db_connectionTlsString}
ports:
- port: 3000
httpSupport: true
start: pnpm start
arjun
arjunOP•4mo ago
okay got it ohh i almost forgot that's how it worked 😭 sucha bad memory thanks for your time

Did you find this page helpful?