#Set root directory on railway.toml?
4 messages · Page 1 of 1 (latest)
Linked Railway resource: 3697c58c / 2e7b60d9 / 90f0596d
New reply sent from Central Station thread:
Hello
gsiniguez;
the root directory cannot be set in railway.toml at all , that option doesn't exist in the config file , you need to set it in the dashboard: go to your service then settings then root directory and set it to /server (and /app for the other service) . once you do that, your dockerfilePath in railway.toml can just be ./Dockerfile. also important: the railway.toml file itself doesn't follow the root directory setting, so you need to set its path in railway as /server/railway.toml explicitly
Hope this help you :)
You're seeing this because this thread has been automatically linked to the Central Station thread.
New reply sent from Central Station thread:
Hey, Ran into the exact same thing a while back with a monorepo setup, so I can share what worked for me.Short answer: railway.toml doesn't have a root directory option. That setting only lives in the service settings on the dashboard (Settings → Source → Root Directory). The TOML file itself is scoped to the service once it's already resolved, so it can't tell Railway where to look for itself bit of a chicken-and-egg thing.What I ended up doing for a mono repo with two Dockerfiles:
On the dashboard, create one service per app (e.g. server and app).
For each service, set the Root Directory to ./server and ./app respectively.
Then in each subfolder, keep a local railway.toml with just:
[build] builder = "DOCKERFILE"
dockerfilePath = "Dockerfile"
Note the path is relative to the root directory you set in the dashboard, not the repo root. That was the part that tripped me up at first I kept writing ./server/Dockerfile and getting the "no such file" error you're describing, because Railway was already cd'd into ./server by the time it read the toml.
If you'd rather keep a single railway.toml at the repo root (which I get, it's cleaner), you can't really Railway reads the toml after applying the root dir, so each service needs its own. The toml at the repo root will just get ignored for services that have a root dir set.One more thing worth checking: make sure the service's Root Directory in the dashboard doesn't have a trailing slash and matches the case of your folder exactly. I lost an hour to that once.
Hope it helps, ping back if the build still fails after setting the root dir per service and I'll take another look.
You're seeing this because this thread has been automatically linked to the Central Station thread.