8 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
8 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
8 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
8 months ago
Oh, now I got it.
8 months ago
Are you using dotenv?
8 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
8 months ago
can you show me your drizzle.config.ts? you can hide any sensitive info there
8 months ago
use process.env.DATABASE_URL
8 months ago
that's the issue
I did this to validate the env as well as soon as keys() is not being used anymore

8 months ago
cool! did it work?
8 months ago
no!
8 months ago
but I see other issue
8 months ago
"no config path provided"
8 months ago
oh nvm it looks for the root one either way
8 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?
8 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.
8 months ago
locally it would work fine
8 months ago
Yes! I'd love an example
8 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

