10 months ago
I am deploying a shared monorepo on Railway with the next-forge template (https://www.next-forge.com)
The problem I am facing is, there's a package called database (I'm using Drizzle) and for me to run the migrations this package needs a .env inside. As it's not an deployable app, I can't put .envs on it inside Railway.
How to proceed on that situation?
34 Replies
10 months ago
Hi! Did you try the "Shared Monorepos" guide?
Yes! I used it to deploy the backend and the frontend, but the database package needs a .env inside to run the migrations. I don't really know how to proceed on that inside Railway
10 months ago
And may I ask why don't you have a .env with the needed vars in that package? That's how turborepo works, all my packages have their own env file
10 months ago
Oh, now I got it.
10 months ago
Are you using dotenv?
10 months ago
and did you set the runtimeEnv property in the env.mjs file?
I did! The problem is: I need to create a ".env" for the database package inside railway. In my local environment it works perfectly because inside the database package I have the .env file, but i need it inside railway as well for it to work and run the migrations
10 months ago
can you show me your drizzle.config.ts? you can hide any sensitive info there
10 months ago
use process.env.DATABASE_URL
10 months ago
that's the issue
I did this to validate the env as well as soon as keys() is not being used anymore

10 months ago
cool! did it work?
10 months ago
no!
10 months ago
but I see other issue
10 months ago
"no config path provided"
10 months ago
oh nvm it looks for the root one either way
10 months ago
This is local, right? could u try in a staging env on railway?
i don't see how it's going to help running on staging env on railway, could you elaborate on that?
10 months ago
I had a project (not a monorepo) that used dotenv to setup env vars, upon deploying on railway it would conflict and would not use the Railway injected env vars.
10 months ago
locally it would work fine
10 months ago
Yes! I'd love an example
10 months ago
In the end I solved it by removing dotenv and upgrading to bun and using Bun.env.
I wonder if nextjs-env is doing something similar with your project

