Sign up for an account on Railway - they have a free tier that is sufficient for small applications.
⌘ + /
shortcut)If a database is not required, select Deploy From Repo.
There are two ways to set up your project on Railway:
npm i -g @railway/cli
# or
yarn global add @railway/cli
railway login
cd /path/to/project
railway link your-project-id
The project ID is taken from the Project Setup page.
Set the SESSION_SECRET_KEY
variable to a random string of 32 characters
and the PORT
variable to 3000
:
railway variables set SESSION_SECRET_KEY=<your_key>
railway variables set PORT=3000
Instead of setting the PORT
here, you could also modify the start
script in the package.json
file to blitz start --port ${PORT-3000}
.
Enter other environment variables that you require. The DATABASE_URL
variable will be automatically set by Railway if you provision a
PostgreSQL database.
Verify that the variables are set correctly via your linked project:
railway variables
Change your build script in package.json to be
NODE_ENV=production blitz build && blitz prisma migrate deploy
so
that the production DB will be migrated on each deploy
Deploy your project
railway up
Once the build is successful and deployment is completed, you will receive the URL for your application that is now accessible via the internet. To get the URL, go to the Deployments section in the project's dashboard and the URL will be listed under a successful deployment.
You may also view your app logs by running
railway logs
In order to set Railway to build + deploy automatically when you push to a branch on your GitHub repository, connect your GitHub repository by following the GUI steps below from Step 2 onward.
Blitz requires the SESSION_SECRET_KEY
variable to be set. Go to your
project on the GUI, select the Variables link and enter
SESSION_SECRET_KEY
as the name of the variable and a random 32-key
secret as its value. Click Add to add the variable.
Set a variable PORT
to 3000
.
Enter other environment variables that you require. The DATABASE_URL
variable will be automatically set by Railway if you provision a database.
Go to the Deployments section. If your project is on GitHub, you can click on Connect GitHub to deploy and connect directly to your repositories on GitHub. Otherwise, you will have to use the CLI to deploy your application.
Select the repository and the branch to deploy from and click Connect + Deploy