Next.js Discord

Discord Forum

Invalid Environment Variables when running a production build inside a docker container

Answered
French Spaniel posted this in #help-forum
Open in Discord
French SpanielOP
Hello,

I am getting the following error, and I am using the t3 stack and following this guide to build and run docker https://create.t3.gg/en/deployment/docker. I have the build working, and the app run but the environment variables are not getting populated properly. I have exec'd into the container and the ran env and I can see they are set, I've also ran node and checked to make sure they were in process.env. I have a env.mjs that does runtime destructuring of the variables. I am not sure what else to do to debug this.

Warning - Configuring keepAlive: false is deprecated. Use { headers: { connection: "close" } } instead.
❌ Invalid environment variables: {
DATABASE_URL: [ 'Required' ],
NEXTAUTH_SECRET: [ 'Required' ],
GOOGLE_CLIENT_ID: [ 'Required' ],
GOOGLE_CLIENT_SECRET: [ 'Required' ],
SECRET_COOKIE_PASSWORD: [ 'Required' ],
STRIPE_PRIVATE_KEY: [ 'Required' ],
EASYPOST_API_KEY: [ 'Required' ]
}
Error: Invalid environment variables
at f (file:///app/node_modules/@t3-oss/env-nextjs/dist/index.mjs:1:386)
at l (file:///app/node_modules/@t3-oss/env-nextjs/dist/index.mjs:1:576)
at C (file:///app/node_modules/@t3-oss/env-nextjs/dist/index.mjs:1:749)
at /app/.next/server/chunks/5495.js:50:74

5 Replies

European sprat
it's a bug
downgrade to 13.4.12
European sprat
Answer
French SpanielOP
Oh, thank you very much! let me try that now

That github issue did not come up in my google searching
European sprat
np i spent like 4 hours last week trying to figure it out before coming across it on github