Inconveniences handling of growing monorepos/turborepos
tvardy
HOBBYOP

9 months ago

I'm experimenting with Railway on my side project for some time. While it's great for quick experiments, I noticed few inconveniences while the project scales up. I'd like to elaborate on them, and maybe some would land as improvement ideas.

Growing list of shared variables

It's sometimes hard to decide if an environment variable should be put in the global project settings or in the service. If I change my mind and rename a variable or change its place, it's not easy to juggle them around; there's lots of clicking. And I end up with at least one failed deployment to make everything run again. Regardless if I first change the variables and then the code reference or vice versa.

I would love to see an option to provide the env vars (or at least the references like VAR_IN_SERVICE_2="${{service1.RAILWAY_PRIVATE_DOMAIN}}:${{service1.PORT}}" - meaning, not containing anything crucial, besides references to other vars) in the railway.json/toml files.

Local development struggles

It's not easy to link the services in the monorepo with their Railway siblings. So I was so far unable to run something like railway run turbo run dev .

I need to run link each service separately and then run each of them separately from their folder in a separate terminal session.

This could also be somehow "handled" by the "config-as-code" feature. Each part of my project has its own railway.json file already. So if the projectId and serviceId could be placed there, maybe the CLI could use it to inject the needed variables.

Single build, multiple deploys

Most of my shared monorepo code is Typescript-based. So I need to call the install and build from the root folder and then am building Docker containers in the service folders. For now... each Dockerfile has its own identical build part. It would greatly improve the time and usage of resources if I could build once and then tell each service to build their own container from their output.

$10 Bounty

14 Replies

tvardy
HOBBYOP

9 months ago

Just remembered one more:

Service dependency

What if I need one service to be up and running for the other one to finish its deploy? I also found out that I can't use private networking during the deployment :(


sim
FREE

8 months ago

What if I need one service to be up and running for the other one to finish its deploy?

Rrailway has this https://docs.railway.com/guides/deployment-actions#deployment-dependencies---startup-ordering


sim
FREE

8 months ago

I also found out that I can't use private networking during the deployment

What do you need it for, they have a way to do database migrations and seeding https://docs.railway.com/reference/config-as-code#pre-deploy-command


sim
FREE

8 months ago

You can have service level variables as well https://docs.railway.com/guides/variables


sim
FREE

8 months ago

Why don't you try to use their CLI? It can help with custom scripts https://docs.railway.com/reference/cli-api


sim

What if I need one service to be up and running for the other one to finish its deploy?Rrailway has this https://docs.railway.com/guides/deployment-actions#deployment-dependencies---startup-ordering

tvardy
HOBBYOP

8 months ago

I missed that in docs. Will have a look.


sim

I also found out that I can't use private networking during the deploymentWhat do you need it for, they have a way to do database migrations and seeding https://docs.railway.com/reference/config-as-code#pre-deploy-command

tvardy
HOBBYOP

8 months ago

Simple example: a NextJS/NuxtJS/SvelteKit (or similar) app connecting to CMS during build time to pre-render (some or all) content pages. So far I can only do this using service's public URL.


sim

You can have service level variables as well https://docs.railway.com/guides/variables

tvardy
HOBBYOP

8 months ago

I'm mentioning in my original post! I'm using vars on project level and service level.

The problem is: relations between the services (at least during the period of project's evolution)

With this simple example from the post above:
1. I have service1 with var PORT=1234
2. I have service2 connecting to the service1, so I define VAR_IN_SERVICE_2="${{service1.RAILWAY_PRIVATE_DOMAIN}}:${{service1.PORT}}" in it

  1. I now do such a simple thing like... rename PORT to PORT_EXT, or service1 to service_1

There's loads of clicking through the dashboard to link that (especially when you have more than 2 services and more than 1-2 relations), and additionally, I also need to change code (+ railway config-as-code) references.


sim

Why don't you try to use their CLI? It can help with custom scripts https://docs.railway.com/reference/cli-api

tvardy
HOBBYOP

8 months ago

Yeah! That's one thing I'm considering - to move the build and deployment to the CI/CD (GitHub Actions, GitLab Actions, Circle CI or whatever).

I could definitely simplify the build to one global call, but would still have the hustle of linking services with their folders.


tvardy

I missed that in docs. Will have a look.

sim
FREE

8 months ago

Sweet!


tvardy

Simple example: a NextJS/NuxtJS/SvelteKit (or similar) app connecting to CMS during build time to pre-render (some or all) content pages. So far I can only do this using service's public URL.

sim
FREE

8 months ago

Yes so you can use the public url and then move to private


sim

Yes so you can use the public url and then move to private

tvardy
HOBBYOP

8 months ago

Why would I need to make the service public just for this step?! stuck_out_tongue emoji This is the inconvenience I'm reporting here stuck_out_tongue emoji


tvardy

Why would I need to make the service public just for this step?! This is the inconvenience I'm reporting here

sim
FREE

8 months ago

Yes, not ideal, I was just suggesting


tvardy

Yeah! That's one thing I'm considering - to move the build and deployment to the CI/CD (GitHub Actions, GitLab Actions, Circle CI or whatever).I could definitely simplify the build to one global call, but would still have the hustle of linking services with their folders.

sim
FREE

8 months ago

What about config as code with their railway.json for every folder and set the project and service IDs? Yes again issue of when the ID changes but less hustle?


Loading...