a month ago
Second question that i am hopping to get an answer on.
I have a mono repo with folders backend and shared. Backend has dependency on shared but how can I copy dependency if I am deploy only backend and railway only packages the backend folder code.
9 Replies
Wondering if I can move the Dockerfile to root but how can I specify which dockerfile to use for the up command if I have multiple Dockerfiles ?
a month ago
the trick is:
don't set any root directory in railway settings , this lets it clone your whole repo including shared folder
add a variable in railway called RAILWAY_DOCKERFILE_PATH and set it to like /backend/Dockerfile (or wherever yours is)
in your dockerfile, since build context is from root, just do:
COPY ./shared ./shared
COPY ./backend ./backend
basically railway always builds from repo root regardless where dockerfile is, you just tell it which dockerfile to use with that env variable. works for multiple services too, each gets its own RAILWAY_DOCKERFILE_PATH
a month ago
i hope this was clear, let me know if you need more clarification
I want to use railway up cli command. is there an option I can pass to it. like fly cli has --dockerfile and --config options
But also can't even run a command from root cause project "is not linked" can we not just pass the project id to the command. It all seems so limited
a month ago
so the issue is the variable name , it's RAILWAY_DOCKERFILE_PATH with underscores, not "RAILWAYDOCKERFILEPATH" all together
here's what actually works:
don't set root directory in your service settings , leave it empty so railway clones your whole repo (both backend and shared folders)
in your service dashboard go to variables tab and add:
RAILWAY_DOCKERFILE_PATH=/backend/Dockerfilefor cli usage from root:
run
railway linkfrom your monorepo root (it'll ask which service to link)then
railway upworksthere's no --dockerfile flag in railway cli like fly has, it uses the service variable instead
in your dockerfile use paths relative to root since build context is always from repo root:
dockerfile
COPY ./shared ./shared
COPY ./backend ./backend
WORKDIR /backendthe key thing is railway cli doesn't have --dockerfile flags. you set RAILWAY_DOCKERFILE_PATH as a service variable in the dashboard (with underscores), and railway up will use it automatically
ilyassbreth
so the issue is the variable name , it's RAILWAY_DOCKERFILE_PATH with underscores, not "RAILWAYDOCKERFILEPATH" all togetherhere's what actually works:don't set root directory in your service settings , leave it empty so railway clones your whole repo (both backend and shared folders)in your service dashboard go to variables tab and add: RAILWAY_DOCKERFILE_PATH = /backend/Dockerfilefor cli usage from root:run railway link from your monorepo root (it'll ask which service to link)then railway up worksthere's no --dockerfile flag in railway cli like fly has, it uses the service variable insteadin your dockerfile use paths relative to root since build context is always from repo root:dockerfileCOPY ./shared ./shared COPY ./backend ./backend WORKDIR /backendthe key thing is railway cli doesn't have --dockerfile flags. you set RAILWAY_DOCKERFILE_PATH as a service variable in the dashboard (with underscores), and railway up will use it automatically
a month ago
That user sent the message on Discord, they had underscores in their original message and they got stripped somehow during the bridge from Discord to CS.
a month ago
Next CLI release will support this <:salute:1137099685417451530>