bootstrap "Config as Code" from a project or a template
mohamnag
HOBBYOP

a year ago

Hi there,

a newbie to Railway here.

I am considering moving a Node.js project to Railway but I have a little bit of concern here regarding future changes.

I want to manage everything (all settings, ...) from code, so I found the "Config as Code" page, however I'm wondering what is the shortest way to find the proper config beside reading through all the config as code docs and trying to make sense of things that I don't yet their equivalent in Railway.

One fast solution I thought of, was to somehow dump the config from a template or from a projected created from that template or even go on and create a project manually and then dump the config of it (like the toml file) using CLI. But I'm not finding any way to do it.

Is there a possibility to get my hands on the effective config of a project?

7 Replies

brody
EMPLOYEE

a year ago

Deploy your project, make the needed changes in the UI, then you can copy the railway.json from the deployments details tab.

Please note that a railway.json is only going to contain settings for a single service, and it's not going to contain environment variables.


mohamnag
HOBBYOP

a year ago

I assume I can have all the JSON files for different services in one folder and point CLI to different ones while deploying from CI right? for the env vars, adding them manually to some of the files won't be hard but for dynamic (like one service pointing to another's ports) is there a solution? I saw that templates have such referencing possibility. (sorry if noob question).


brody
EMPLOYEE

a year ago

Yes you can have multiple railway.json files, like a api.railway.json and a frontend.railway.json but you would set the applicable railway.json file in the service settings, not with the cli as it does not have / need such a feature.

For environment variables, you need to add them with the UI to the service in the variables tab, please do not set environment variables in plaintext files. You can also reference variables this way.


mohamnag
HOBBYOP

a year ago

thanks for all the info. I did try to setup things and it looks like to me that there is no way of reproducing a project or at least a full environment with no UI interactions. This is bad for me as I need to be able to fully automate it. It might work for bootstrapping something manually and just pushing gradual updates (remembering to go and edit env vars in UI in case changes are needed) but nothing close to "config as code"


brody
EMPLOYEE

a year ago

How would you handle secrets with no UI interactions? that sounds like you'd eventually end up with something in plaintext that shouldn't be, I don't even work for Railway and I've seen countless database credentials sitting in GitHub repos.

I saw your message in the feature request post, and unfortunately I can't see how creating a project from a config is better than doing it from the UI.

Sure maybe Railway's UI takes some getting used to, but once you're used to it, it works great and you can be very productive with it, if you want to use Railway but not the UI then IMO you would be better off with a VM and docker compose up.


mohamnag
HOBBYOP

a year ago

sorry for misunderstanding regarding being affiliated with Railway. no, secrets need to be generated and stored by a secret manager, you don't really need to have them you should only be able to reference them.

Terraform drivers have many good examples of how, like using Vault and co.Creating a project from a file has the advantage of reproducibility. I can use it for simple stuff like starting up temporary environments or projects for experimental features (what Railway has for direct GitHub integration and its PRs) up to spinning up a copy of a solution I already have for one customer for another but all automated and with no clicks through UI.

Interesting is that Railway actually has this internally (look at templates) but they are not exposing it to outside.This concept is not really new, look at terraform, look at k8s, or simpler ones like heroku.


brody
EMPLOYEE

a year ago

Railway is nothing without the UI so it you don't want to utilise the UI then I really can't recommend Railway.


Loading...