R
Railway12mo ago
Muijf

NextJS build step service variables.

I am using T3 Env (https://env.t3.gg/docs/nextjs#validate-schema-on-build-(recommended)) and also import the env variables inside the next.config.js. But my service variables don't get included. It'll only work if I include an .env file inside my repository.
Env
Never build your apps with invalid environment variables again. Validate and transform your environment with the full power of Zod.
13 Replies
Percy
Percy12mo ago
Project ID: 4eb1e97a-a2b5-4165-a985-b3538e1e2109
Muijf
MuijfOP12mo ago
4eb1e97a-a2b5-4165-a985-b3538e1e2109
Brody
Brody12mo ago
are you building with a dockerfile?
Muijf
MuijfOP12mo ago
yes anything I have to do differently if I use a dockerfile?
Muijf
MuijfOP12mo ago
Ah I just looked that up Thanks. Makes sense
Brody
Brody12mo ago
not specific to railway, but its easy to overlook since nixpacks will do that all for you automatically
Muijf
MuijfOP12mo ago
ARG VAR_NAME ENV $VAR_NAME then prob right?
Brody
Brody12mo ago
nope, just as the docs say, no need for ENV
Muijf
MuijfOP12mo ago
Alright It's confusing because it's showing an example where they echo it But I want it to actually be in the env We'll see
Brody
Brody12mo ago
ARG brings the variable into the build environment, during runtime all service variables will be injected automatically
Muijf
MuijfOP12mo ago
Yeah thanks. I did need to use ENV so they can be picked up in the NextJS build step. I got it now But ARG brings it into dockerfile, that's true
Brody
Brody12mo ago
you shouldn't have needed to use ENV, ARG bring the variable into the environment during build
Want results from more Discord servers?
Add your server