railwayapp / cli

Railway CLI
https://railway.app
MIT License
321 stars 83 forks source link

Update `railway add` #570

Closed Milo123459 closed 1 week ago

Milo123459 commented 3 weeks ago

This allows users to create services and databases in the linked project and environment, with similar options to the + Create menu found within the project canvas.

Changes and improvements are outlined below.

image

image image
brody192 commented 3 weeks ago

I agree having add as a single way of adding any kind of service(s) -- eventually bringing feature parity with the + Create modal in the project canvas.

For now, I think the format of railway add --service hello-world would fit best with how railway add currently works.

railway add --service -> Creates an empty service with a random name. railway add --service hello-world -> Creates an empty service with the specified name.

And you can provide either a --repo or an --image flag to set the source, omitting them creates an empty service.

railway add --service hello-world --repo "brody192/hello-world" -> Creates a service that deploys from the given repo with the specified name. railway add --service hello-world --image ubuntu -> Creates a service that deploys from the given image with the specified name.

Additionally, you would also be able to pass --variables to the --service flag in k=v format.

railway add --service hello-world --variables "VARIABLE=VALUE" -> Creates an empty service with the specified name and the specified variable(s).

For the interactive flow when running just railway add it should prompt similarly to how the + Create button does.

GitHub Repo Database Docker Image Empty Service

With all the same flag-based functionality but fully interactive.

We can worry about deploying templates via railway add at a later time.

Why though?

This brings us a few steps closer to parity with the dashboard, meaning if you love the terminal you now can stay in it a little longer!

But for a real world scenario, this allows users to add variables to a service prior to deployment, this means less unnecessary redeployments due to having to add variables via the dashboard and then redeploy.