R
Railwayā€¢15mo ago
acronie

Monorepo

If I am inside monorepo how will assigning domain work I wanna asign domain in two aspects
85 Replies
Percy
Percyā€¢15mo ago
Project ID: N/A
Brody
Brodyā€¢15mo ago
lets say your monorepo has two services, this means you will need two railway services, and this also means each service will have its own domain
acronie
acronieOPā€¢15mo ago
so change root directory?
Brody
Brodyā€¢15mo ago
yes, you would need to set the root directory in each of the services settings
acronie
acronieOPā€¢15mo ago
oh and variables too? I have dotenv-cli setup for my root hmmm what if it's a shared monorepo tho
acronie
acronieOPā€¢15mo ago
but then what about port my backend is on 8000 and frontend on 3000
Brody
Brodyā€¢15mo ago
you still need two services
acronie
acronieOPā€¢15mo ago
hmmm so technically how am I going to share stuff šŸ˜“
Brody
Brodyā€¢15mo ago
the source is still the same repo
acronie
acronieOPā€¢15mo ago
I don't understandd šŸ˜…
acronie
acronieOPā€¢15mo ago
No description
Brody
Brodyā€¢15mo ago
by chance have you read that docs section i linked?
acronie
acronieOPā€¢15mo ago
yea
acronie
acronieOPā€¢15mo ago
I have this command setup to run everything
No description
acronie
acronieOPā€¢15mo ago
for now since I have not yet laid the build script to build my monorepo not my main motive rn
Brody
Brodyā€¢15mo ago
you need two services, please reference the docs section i linked
acronie
acronieOPā€¢15mo ago
ill check once again
Brody
Brodyā€¢15mo ago
i assume this is a frontend and backend?
acronie
acronieOPā€¢15mo ago
yea
The start command can be overridden in the Railway settings ( eg. npm run start:backend and npm run start:frontend).
but I only have one service right šŸ¤”
Brody
Brodyā€¢15mo ago
you need two services
acronie
acronieOPā€¢15mo ago
that I get but I don't get how will it be shared
Brody
Brodyā€¢15mo ago
the source of the service is the same repo
acronie
acronieOPā€¢15mo ago
so i remove deployments from this? the "root"
Brody
Brodyā€¢15mo ago
what
acronie
acronieOPā€¢15mo ago
like the start commands
acronie
acronieOPā€¢15mo ago
No description
acronie
acronieOPā€¢15mo ago
from deel I remove the commands to start?
Brody
Brodyā€¢15mo ago
how many services in your repo do you have? just a frontend and backend?
acronie
acronieOPā€¢15mo ago
yes.
Brody
Brodyā€¢15mo ago
then you need 2 services, it looks like you have 3 one service for the frontend, and one service for the backend
acronie
acronieOPā€¢15mo ago
and connect them both to the root of my monorepo but run only "one" am I right?
Brody
Brodyā€¢15mo ago
you would need to set the appropriate build and start commands for both services
acronie
acronieOPā€¢15mo ago
Ohk I will try thanks
acronie
acronieOPā€¢15mo ago
why does it keep on killing itself
No description
acronie
acronieOPā€¢15mo ago
sadcat
Brody
Brodyā€¢15mo ago
you're on the trial plan, and are likely trying to use more than 512mb of ram
acronie
acronieOPā€¢15mo ago
oh hm
Brody
Brodyā€¢15mo ago
upgrade time!!
acronie
acronieOPā€¢15mo ago
yea
Brody
Brodyā€¢15mo ago
šŸ„³
acronie
acronieOPā€¢15mo ago
I just did
Brody
Brodyā€¢15mo ago
šŸ„³ šŸ„³ welcome to the club
acronie
acronieOPā€¢15mo ago
haha it still didn't work idk wth is wrong I am trying something else
Brody
Brodyā€¢15mo ago
did you get the same killed?
acronie
acronieOPā€¢15mo ago
Yea
Brody
Brodyā€¢15mo ago
that's not ideal
acronie
acronieOPā€¢15mo ago
Ohk i think it works now was a turbo repo issue ig
Brody
Brodyā€¢15mo ago
hobby plan is where it's at anyway
acronie
acronieOPā€¢15mo ago
yea thats not a problem needed the upgrade either ways but my url doesn't serve anything the app seems to be running
Brody
Brodyā€¢15mo ago
what status code do you get
acronie
acronieOPā€¢15mo ago
404
acronie
acronieOPā€¢15mo ago
No description
Brody
Brodyā€¢15mo ago
I still see dev, please do not run anything in development mode
acronie
acronieOPā€¢15mo ago
yea its on purpose
Brody
Brodyā€¢15mo ago
404 for every route?
acronie
acronieOPā€¢15mo ago
yea
acronie
acronieOPā€¢15mo ago
No description
acronie
acronieOPā€¢15mo ago
its compiling tho so idk whats happening
Brody
Brodyā€¢15mo ago
the next app should compile (build) in the build stage, and you shouldn't run dev on railway
acronie
acronieOPā€¢15mo ago
mhm okay I will try build
Brody
Brodyā€¢15mo ago
next build and next start, that's all you should need, maybe some prisma stuff too
acronie
acronieOPā€¢15mo ago
trying
Brody
Brodyā€¢15mo ago
so what kind of backend is this? if next is the frontend
acronie
acronieOPā€¢15mo ago
it's not a backend it's just some services which I need
Brody
Brodyā€¢15mo ago
welp you said yes to backend and frontend when I asked, so I can only go off what you said
acronie
acronieOPā€¢15mo ago
Welp technically a backend over a backend Hard to explain :p Okay build worked
Brody
Brodyā€¢15mo ago
šŸ„³
acronie
acronieOPā€¢15mo ago
deel-web:start: Error: Cannot find module '.prisma/client/index'

deel-web:start: Require stack:
deel-web:start: Error: Cannot find module '.prisma/client/index'

deel-web:start: Require stack:
this after I setup my services I don't know whats wrong šŸ¤” maybe because they're sharing same scope and it's overwriting in some way Works perfectly fine locally. So I am not sure
Brody
Brodyā€¢15mo ago
even though the two services share the same source they do not share the same filesystem
acronie
acronieOPā€¢15mo ago
hmmm
Brody
Brodyā€¢15mo ago
what version of node are you using locally?
acronie
acronieOPā€¢15mo ago
20.6.0
Brody
Brodyā€¢15mo ago
railway uses node 16 by default
acronie
acronieOPā€¢15mo ago
idts that should be an issue here
Brody
Brodyā€¢15mo ago
oh you'd be surprised I'm not saying it is the issue, but it couldn't hurt to try unfortunately railway only supports up to node 18 natively but let's try that anyway, set engines.node to 18 in your package.json
acronie
acronieOPā€¢15mo ago
lemme try if its working on node 18 locallu
Brody
Brodyā€¢15mo ago
even if it does, railway is a docker environment, it's a whole other ball game if you never developed your app with a docker deployment in mind
acronie
acronieOPā€¢15mo ago
The main issue is it's looking for prisma client and it's not able to find it can test that is their anyway to directly serve docker images then? that should be easier I could just publish images directly and have everything running but I am afraid that would need two services too?
Brody
Brodyā€¢15mo ago
there is, but that would require you write a dockerfile
acronie
acronieOPā€¢15mo ago
completely fine w that too If it saves me from two services somehow?
Brody
Brodyā€¢15mo ago
well if you know how to write a dockerfile, write the dockerfile and let railway build with the dockerfile no need to publish an image
acronie
acronieOPā€¢15mo ago
it will build the services itself? or can I give it the whole monorepo and two ports two handle inside one service
Brody
Brodyā€¢15mo ago
you give it a Dockerfile and it will build the service using that dockerfile
acronie
acronieOPā€¢15mo ago
hmm is their any example of dockerfile for monorepo on railway? For the services and stuff and handling the whole monorepo and all
FROM node

ARG RAILWAY_ENVIRONMENT
ENV RAILWAY_ENVIRONMENT=$RAILWAY_ENVIRONMENT


COPY . ./app
RUN cd ./app
RUN npm install
RUN npm run build
CMD npm run start
FROM node

ARG RAILWAY_ENVIRONMENT
ENV RAILWAY_ENVIRONMENT=$RAILWAY_ENVIRONMENT


COPY . ./app
RUN cd ./app
RUN npm install
RUN npm run build
CMD npm run start
will something bare minimum like this work out of the box like for domains too or do I need to write docker file for each. Idk whats wrong sometimes it deploys just fine and sometimes it doesn't want to ik it doesn't make sense but that is what is happening "build": "dotenv -e ../../.env prisma db push && dotenv -e ../../.env prisma generate && next build", this is how my build script looks\ rn it says prisma client generated too deel-web:start: Error: Cannot find module '.prisma/client/index'` but it's disappearing apparantely it's strange sometimes it wants to work sometimes it doesn't Lemme know if anyone has anything for me šŸ˜¦ do these services run in different environment or same I get my one service running and other stops working gives me a feeling that theyre running in shared context ( hard to debug things as well )
Want results from more Discord servers?
Add your server