2 years ago
I am trying to understand how relative paths work in railway.json file.
For example, if I have railway.json and Dockerfile file at ./packages/api directory.
Does Railway will consider ./packages/api as base directory? Will that be same for Dockerfile as well?
28 Replies
2 years ago
Will that be same for
Dockerfileas well?
If I want to copy the files only in./packages/apidirectory.
Will this work COPY . .?
2 years ago
in this scenario do you have a root directory set?
2 years ago
I don't see any property available on railway config to set a root directory.https://railway.app/railway.schema.json
2 years ago
its in the service settings
2 years ago
ah! I see.
a follow up question
2 years ago
If I set a root directoy from the UI.
2 years ago
Will railway.json and Dockerfile both respect this root directory?
2 years ago
they should be, if they arent then thats a bug.
but this sounds like a shared monorepo, you wouldn't want to set any root directory for that kind of structure.
and in that case that means the base directory would be the root of the project
2 years ago
they should be, if they arent then thats a bug.
Okie, I will try it.but this sounds like a shared monorepo, you wouldn't want to set any root directory for that kind of structure.
I trying to deploy micro-services, with all the code stored in a single repo and each micro-service has it's ownrailway.jsonandDockerfile.
2 years ago
do these mico services share code with one another
2 years ago
nope (as of now)
2 years ago
I don't think you should be setting a root directory then, doing so may get you going now but could bite you in the butt later
2 years ago
oh! Can you please share a small example, how it could effect later?
2 years ago
Also, I tried setting the root directory from the UI./packages/api
but then I was even for the railway.json file path in the UI.
I had to use full path ./packages/api/railway.json.
Just by using railway.json was failing the build.
Is this expected behaviour?
2 years ago
setting a root directory will only copy in that directory, your code will not be able to access the code from other pages because it will not exist.
I had to use full path … Is this expected behaviour
yes, you need to specify the full path to the railway.json file
2 years ago
I had to use full path … Is this expected behaviour
yes, you need to specify the full path to the railway.json file
Gotcha, thanks for confirmation.
Should I submit a PR in railway docs to add this info?
2 years ago
im sure that would be a great addition
2 years ago
setting a root directory will only copy in that directory, your code will not be able to access the code from other pages because it will not exist.
Interesting, that's definitely a valid point. I will keep that in mind. Thanks.
2 years ago
On it.
2 years ago
2 years ago
added a review
2 years ago
I don't see any review/comments on the PR?
2 years ago
its 100% there

2 years ago
it's in pending state, you might have to submit that review. (i think that how it works in gh)
2 years ago
ill just send it here then lol -
Perhaps this would flow better -
**Note:** The **Railway Config File** does not follow the **Root Directory** path. You have to specify the absolute path for the `railway.json` or `railway.toml` file.same for the other place you added the text
2 years ago
updated 🙂
2 years ago
cool, im sure a team member will see it in the coming days
2 years ago
the PR was merged, but in the future please do not tag any team members, even if you see them active on github.