Skip to content

Latest commit

 

History

History
141 lines (91 loc) · 3.05 KB

cli.md

File metadata and controls

141 lines (91 loc) · 3.05 KB
title CLI

Use the Railway CLI to connect your code to your projects infrastructure without needing to worry about environment variables or configuration.

Install

Install with Brew, NPM or Scoop.

Homebrew

brew install railwayapp/railway/railway

NPM

npm i -g @railway/cli

Shell Script

sh -c "$(curl -sSL https://raw.githubusercontent.com/railwayapp/cli/master/install.sh)"

Scoop

Use this method if you prefer to interact with Railway using a native Windows binary.

scoop bucket add railway https://github.com/railwayapp/scoop-railway; scoop install railway/railway

For additional documentation on Scoop, see here.

Source

You can also download the prebuilt binary directly or build from source.

Login

Login to your Railway account. Opens a browser tab which authenticates into an existing Railway session.

railway login

If there are any issues with Browser based login you can use the --browserless flag to authenticate.

Project Token

You can use Project tokens to authenticate in environments that prevent you to authenticate with browsers such as CI environments.

Project tokens allow the CLI to access all the environment variables associated with a specific project and environment. Use the token by setting the RAILWAY_TOKEN environment variable and then running railway run.

RAILWAY_TOKEN=XXXX railway run

Link to a Project

Link to an existing Project under your Railway account or team.

Screenshot of Railway

railway link <projectId>

Create a Project

Create a new project directly from the command line.

railway init

Run

Run code inside your Railway environment. We connect your code to your infrastructure hosted on Railway by injecting environment variables.

railway run <cmd>

For example, to run your node project with Railway:

railway run npm start

If you have a Dockerfile in your project directory, you can just run railway run with no arguments to build and run the Dockerfile.

Environments

Projects might have multiple environments, by default the CLI points to the production environment. If you'd like to use a different set of environment variables and a different deployment environment you can change the setting by:

railway environment

Deploy

Deploy current directory to Railway. Displays deployment logs from the project deploys.

railway up

Add Plugin

Provision a plugin for a project.

railway add

Connect to Plugin

Open an interactive shell to a database directly in the CLI.

railway connect

Logout

railway logout