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
Project ID:
4eb1e97a-a2b5-4165-a985-b3538e1e2109
4eb1e97a-a2b5-4165-a985-b3538e1e2109
are you building with a dockerfile?
yes
anything I have to do differently if I use a dockerfile?
Ah I just looked that up
Thanks. Makes sense
not specific to railway, but its easy to overlook since nixpacks will do that all for you automatically
ARG VAR_NAME
ENV $VAR_NAME then prob right?
nope, just as the docs say, no need for ENV
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
ARG brings the variable into the build environment, during runtime all service variables will be injected automatically
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
you shouldn't have needed to use ENV, ARG bring the variable into the environment during build