Deploying Monorepo with Next-Forge
pedroota
HOBBYOP

a year 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?

$10 Bounty

34 Replies

pedroota
HOBBYOP

a year ago

6452898b-4334-4a3f-b118-d8bfb71e8f8c


a year ago

Hi! Did you try the "Shared Monorepos" guide?


pedroota
HOBBYOP

a year ago

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


a year 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


pedroota
HOBBYOP

a year ago

I do have! But I need to add the envs inside the package on Railway too


a year ago

Oh, now I got it.


pedroota
HOBBYOP

a year ago

Yes, that's the problem


a year ago

Are you using dotenv?


pedroota
HOBBYOP

a year ago

hmm, nope


pedroota
HOBBYOP

a year ago

I am using a package called @t3-oss/env-nextjs


a year ago

and did you set the runtimeEnv property in the env.mjs file?


pedroota
HOBBYOP

a year ago

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


a year ago

can you show me your drizzle.config.ts? you can hide any sensitive info there


pedroota
HOBBYOP

a year ago

Of course!

1398105580471844995


a year ago

use process.env.DATABASE_URL


a year ago

that's the issue


pedroota
HOBBYOP

a year ago

I did this to validate the env as well as soon as keys() is not being used anymore

1398106326709571796


a year ago

cool! did it work?


pedroota
HOBBYOP

a year ago

Not yet!

1398106689252888679


pedroota
HOBBYOP

a year ago

Do I need to keep the .env inside /database package?


a year ago

no!


a year ago

but I see other issue


a year ago

"no config path provided"


a year ago

oh nvm it looks for the root one either way


pedroota
HOBBYOP

a year ago

yes!


a year ago

This is local, right? could u try in a staging env on railway?


pedroota
HOBBYOP

a year ago

yes! it's in local environment


pedroota
HOBBYOP

a year ago

i don't see how it's going to help running on staging env on railway, could you elaborate on that?


a year 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.


a year ago

locally it would work fine


pedroota
HOBBYOP

a year ago

Yes! I'd love an example


pedroota
HOBBYOP

a year ago

hmm, i dont think it's related to that tbh


pedroota
HOBBYOP

a year ago

but ill try


a year 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


Welcome!

Sign in to your Railway account to join the conversation.

Loading...