R
Railway•4mo ago
Yashu

Relative path in railway.json file

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?
24 Replies
Percy
Percy•4mo ago
Project ID: N/A
Yashu
YashuOP•4mo ago
Will that be same for Dockerfile as well?
If I want to copy the files only in ./packages/api directory. Will this work COPY . .?
Brody
Brody•4mo ago
in this scenario do you have a root directory set?
Yashu
YashuOP•4mo ago
I don't see any property available on railway config to set a root directory. https://railway.app/railway.schema.json
Brody
Brody•4mo ago
its in the service settings
Yashu
YashuOP•4mo ago
ah! I see. a follow up question If I set a root directoy from the UI. Will railway.json and Dockerfile both respect this root directory?
Brody
Brody•4mo 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
Yashu
YashuOP•4mo 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 own railway.json and Dockerfile.
Brody
Brody•4mo ago
do these mico services share code with one another
Yashu
YashuOP•4mo ago
nope (as of now)
Brody
Brody•4mo 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
Yashu
YashuOP•4mo ago
oh! Can you please share a small example, how it could effect later? 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?
Brody
Brody•4mo 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
Yashu
YashuOP•4mo 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?
Brody
Brody•4mo ago
im sure that would be a great addition
Yashu
YashuOP•4mo 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. On it.
Brody
Brody•4mo ago
added a review
Yashu
YashuOP•4mo ago
I don't see any review/comments on the PR?
Brody
Brody•4mo ago
its 100% there
No description
Yashu
YashuOP•4mo ago
it's in pending state, you might have to submit that review. (i think that how it works in gh)
Brody
Brody•4mo 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.
**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
Yashu
YashuOP•4mo ago
updated 🙂
Brody
Brody•4mo ago
cool, im sure a team member will see it in the coming days the PR was merged, but in the future please do not tag any team members, even if you see them active on github.
Want results from more Discord servers?
Add your server