config-as-code questions regarding paths and configuration precedence
arnorhs
PROOP

9 days ago

I have my services in my monorepo set up as separate services on railway, and I've always configured them through the UI, which is mostly fine, but I'm interested in configuring them using the config-as-code feature - mostly, so that when i rename libraries etc I can update the watch paths during the same deployment.

I'm also interested in generating the railway config file in code, so i can compute the watch paths based on the turbo repo dependency graph.

So a few questions, that don't seem to be addressed in the guide or the reference.

1) Is there a way to extract the current service's config as it is defined in the UI as a new railway.json file?

2) If i define my docker files' locations for each respective service using their corresponding railway.json file - do i specify the path of the dockerfile relative to the location of the railway.json file, or relative to the project root (like in the UI)?

3) if I can't do 1), and miss a setting when manually trying ot re-create my config as a railway.json, will the settings currently in the UI get overwritten by this new config? And if not, will one have precedence over the other?

ps. These questions aren't really related to a particular project or service, they are stictly general question, but I'll put my project id here so the bot doesn't complain:

Project id: 58cd7410-04d6-4c6e-a74d-fa7c78455231

0 Replies

1) IIRC no, there isn't a way to just export all the settings into a config
2) I would just suggest directly using a compose file if you have multiple Dockerifles nested in your project


arnorhs
PROOP

9 days ago

re 2) - interesting - last time i checked you can only bootstrap a project based on a docker compose file, but you can't reference that as a global configuration thing for your railway services.

do you have a link to the docs relating to this? i can't find anything relating to using docker compose aside from initial bootstrap.

it's not referenced in the config-as-code docs either


Wait nevermind Railway doesn't do compose 😭
Sorry


What you can do, is deploy multiple services from the monorepo, but you can configure individual Dockerfile paths for each service.
Still, don't think you can do that in a json/toml configuration file.


https://docs.railway.com/guides/dockerfiles#docker-compose
It seems like it does support compose to a certain extent


Drag and drop compose into the canvas


Yeah I just realized lol mb


arnorhs
PROOP

9 days ago

to be clear, and so this thread doesn't get derailed.. I already have my services deployed as multiple services in railway - and I've been running them on railway for 3 years now - and how the docker containers are deployed are not really the subject of this thread. it is simply off topic.

i'm specifically asking about the config-as-code feature, and the specifics of how it works in relation to an existing project, where everything so far has been configured using the UI


arnorhs
PROOP

6 days ago

So is there a railway person that can chime in on this? I still don't have an answer to 2) and 3)


arnorhs
PROOP

5 days ago

bump


arnorhs
PROOP

4 days ago

should I just start a new thread?


2) If you just give it a relative path, it will go off of the selected root path. If you add a / before it, it will go from the container root.

3) Railway.json will ALWAYS override the UI. The UI will stop you from making changes as well.


Loading...