R
Railwayā€¢14mo ago
acronie

Monorepo

If I am inside monorepo how will assigning domain work I wanna asign domain in two aspects
85 Replies
Percy
Percyā€¢14mo ago
Project ID: N/A
Brody
Brodyā€¢14mo 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
acronieā€¢14mo ago
so change root directory?
Brody
Brodyā€¢14mo ago
yes, you would need to set the root directory in each of the services settings
acronie
acronieā€¢14mo ago
oh and variables too? I have dotenv-cli setup for my root hmmm what if it's a shared monorepo tho
acronie
acronieā€¢14mo ago
but then what about port my backend is on 8000 and frontend on 3000
Brody
Brodyā€¢14mo ago
you still need two services
acronie
acronieā€¢14mo ago
hmmm so technically how am I going to share stuff šŸ˜“
Brody
Brodyā€¢14mo ago
the source is still the same repo
acronie
acronieā€¢14mo ago
I don't understandd šŸ˜…
acronie
acronieā€¢14mo ago
No description
Brody
Brodyā€¢14mo ago
by chance have you read that docs section i linked?
acronie
acronieā€¢14mo ago
yea
acronie
acronieā€¢14mo ago
I have this command setup to run everything
No description
acronie
acronieā€¢14mo ago
for now since I have not yet laid the build script to build my monorepo not my main motive rn
Brody
Brodyā€¢14mo ago
you need two services, please reference the docs section i linked
acronie
acronieā€¢14mo ago
ill check once again
Brody
Brodyā€¢14mo ago
i assume this is a frontend and backend?
acronie
acronieā€¢14mo 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ā€¢14mo ago
you need two services
acronie
acronieā€¢14mo ago
that I get but I don't get how will it be shared
Brody
Brodyā€¢14mo ago
the source of the service is the same repo
acronie
acronieā€¢14mo ago
so i remove deployments from this? the "root"
Brody
Brodyā€¢14mo ago
what
acronie
acronieā€¢14mo ago
like the start commands
acronie
acronieā€¢14mo ago
No description
acronie
acronieā€¢14mo ago
from deel I remove the commands to start?
Brody
Brodyā€¢14mo ago
how many services in your repo do you have? just a frontend and backend?
acronie
acronieā€¢14mo ago
yes.
Brody
Brodyā€¢14mo ago
then you need 2 services, it looks like you have 3 one service for the frontend, and one service for the backend
acronie
acronieā€¢14mo ago
and connect them both to the root of my monorepo but run only "one" am I right?
Brody
Brodyā€¢14mo ago
you would need to set the appropriate build and start commands for both services
acronie
acronieā€¢14mo ago
Ohk I will try thanks
acronie
acronieā€¢14mo ago
why does it keep on killing itself
No description
acronie
acronieā€¢14mo ago
sadcat
Brody
Brodyā€¢14mo ago
you're on the trial plan, and are likely trying to use more than 512mb of ram
acronie
acronieā€¢14mo ago
oh hm
Brody
Brodyā€¢14mo ago
upgrade time!!
acronie
acronieā€¢14mo ago
yea
Brody
Brodyā€¢14mo ago
šŸ„³
acronie
acronieā€¢14mo ago
I just did
Brody
Brodyā€¢14mo ago
šŸ„³ šŸ„³ welcome to the club
acronie
acronieā€¢14mo ago
haha it still didn't work idk wth is wrong I am trying something else
Brody
Brodyā€¢14mo ago
did you get the same killed?
acronie
acronieā€¢14mo ago
Yea
Brody
Brodyā€¢14mo ago
that's not ideal
acronie
acronieā€¢14mo ago
Ohk i think it works now was a turbo repo issue ig
Brody
Brodyā€¢14mo ago
hobby plan is where it's at anyway
acronie
acronieā€¢14mo 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ā€¢14mo ago
what status code do you get
acronie
acronieā€¢14mo ago
404
acronie
acronieā€¢14mo ago
No description
Brody
Brodyā€¢14mo ago
I still see dev, please do not run anything in development mode
acronie
acronieā€¢14mo ago
yea its on purpose
Brody
Brodyā€¢14mo ago
404 for every route?
acronie
acronieā€¢14mo ago
yea
acronie
acronieā€¢14mo ago
No description
acronie
acronieā€¢14mo ago
its compiling tho so idk whats happening
Brody
Brodyā€¢14mo ago
the next app should compile (build) in the build stage, and you shouldn't run dev on railway
acronie
acronieā€¢14mo ago
mhm okay I will try build
Brody
Brodyā€¢14mo ago
next build and next start, that's all you should need, maybe some prisma stuff too
acronie
acronieā€¢14mo ago
trying
Brody
Brodyā€¢14mo ago
so what kind of backend is this? if next is the frontend
acronie
acronieā€¢14mo ago
it's not a backend it's just some services which I need
Brody
Brodyā€¢14mo ago
welp you said yes to backend and frontend when I asked, so I can only go off what you said
acronie
acronieā€¢14mo ago
Welp technically a backend over a backend Hard to explain :p Okay build worked
Brody
Brodyā€¢14mo ago
šŸ„³
acronie
acronieā€¢14mo 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ā€¢14mo ago
even though the two services share the same source they do not share the same filesystem
acronie
acronieā€¢14mo ago
hmmm
Brody
Brodyā€¢14mo ago
what version of node are you using locally?
acronie
acronieā€¢14mo ago
20.6.0
Brody
Brodyā€¢14mo ago
railway uses node 16 by default
acronie
acronieā€¢14mo ago
idts that should be an issue here
Brody
Brodyā€¢14mo 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
acronieā€¢14mo ago
lemme try if its working on node 18 locallu
Brody
Brodyā€¢14mo 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
acronieā€¢14mo 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ā€¢14mo ago
there is, but that would require you write a dockerfile
acronie
acronieā€¢14mo ago
completely fine w that too If it saves me from two services somehow?
Brody
Brodyā€¢14mo 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
acronieā€¢14mo 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ā€¢14mo ago
you give it a Dockerfile and it will build the service using that dockerfile
acronie
acronieā€¢14mo 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