Railway is a managed hosting platform which allows you to deploy and scale your Vendure server and infrastructure with ease.
This guide should be runnable on the Railway free trial plan, which means you can deploy it for free and thereafter pay only for the resources you use, which should be around $5 per month.
First of all you'll need to create a new Railway account (click "login" on the website and enter your email address) if you don't already have one.
You'll also need a GitHub account and you'll need to have your Vendure project hosted there.
In order to use the Railway trial plan, you'll need to connect your GitHub account to Railway via the Railway dashboard.
If you'd like to quickly get started with a ready-made Vendure project which includes sample data, you can clone our Vendure one-click-deploy repo.
Railway defines the port via the PORT environment variable, so make sure your Vendure Config uses this variable:
The following is already pre-configured if you are using the one-click-deploy repo.
Make sure your DB connection options uses the following environment variables:
The following is already pre-configured if you are using the one-click-deploy repo.
In this guide we will use the AssetServerPlugin's default local disk storage strategy. Make sure you use the
ASSET_UPLOAD_DIR environment variable to set the path to the directory where the uploaded assets will be stored.
From the Railway dashboard, click "New Project" and select "Empty Project". You'll be taken to a screen where you can add the first service to your project.
Click the "Add a Service" button and select "database". Choose a database that matches the one you are using in your Vendure project. If you are following along using the one-click-deploy repo, then choose "Postgres".
Click the "new" button to create a new service, and select "GitHub repo". Select the repository which contains your Vendure project. You may need to configure access to this repo if you haven't already done so.
You should then see a card representing this service in the main area of the dashboard. Click the card and go to the "settings" tab.
node ./dist/index.js.In order to persist the uploaded product images, we need to create a volume. Click the "new" button and select "Volume".
Attach it to the "vendure-server" service and set the mount path to /vendure-assets.
Click on the "vendure-server" service and go to the "Variables" tab. This is where we will set up the environment variables which are used in our Vendure Config. You can use the raw editor to add the following variables, making sure to replace the highlighted values with your own:
The variables starting with ${{Postgres...}} assume that your database service is called "Postgres". If you have
named it differently, then you'll need to change these variables accordingly.
Finally, we need to define the worker process which will run the background tasks. Click the "new" button and select "GitHub repo". Select again the repository which contains your Vendure project.
You should then see a card representing this service in the main area of the dashboard. Click the card and go to the "settings" tab.
node ./dist/index-worker.js.The worker will need to know how to connect to the database, so add the following variables to the "Variables" tab:
To test that everything is working, click the "vendure-server" card and then the link to the temporary domain.
This setup gives you a basic Vendure server to get started with. When moving to a more production-ready setup, you'll want to consider the following: