Step-by-step instructions to deploy your application on Railway
Go to railway.com (you want 20$ in credits? Take the Pro-version of the Nodejs-Enterprise-Launchpad-v2 template)
Signup or login to your account.
Create a new empty Project.
You will have an empty area like this.
Open the project in the browser folder and drag and drop the docker-compose-postgres.railway.yml file. This will create a new "db" service.
Click "Deploy" to deploy the db service.
Once the db service gets deployed, go ahead and drag and drop the next file docker-compose.redis.railway.yml to create the redis service.
Deploy the Redis service.
Now we need to deploy the app. Make sure to push it into a new github repo, then in railway project, click on the "Create" button.
Choose your github repo (you may need to connect your github account and allow railway to access your repos including private ones).
Before hitting "Deploy", we need to change some settings. Click on the nodejs app card to access the configurations UI. then navigate to the settings tab.
At the very bottom you will find a section named "Config-as-code". In the Railway config file input choose railway.toml
In the Networking section and under "Public Networking" click on "Generate Domain".
Now switch to the "Variables" panel. Ignore all the "Suggested Variables".
Go ahead and click on "Raw Editor".
Open the nodejs project on VSCode and open the .env.railway file. Copy its entire content and paste it inside the "Raw editor" on Railway.
You may want to edit your environment variables like adding your Cloudflare endpoint and API keys.
Keep all the variables values that look like this ${{db.DATABASE_URL_PRIVATE}} or ${{redis.VARIABLE}} (you may want to change the demo variable to false).
Click on "Update Variables".
You should notice that the Node.js app (from github repo) is now connected to the other "db" and "redis" services.
If your not seeing the arrows connecting the app to the services, make sure that your services has the exact names "db" and "redis". You can edit them like shown in the images.
Now you can finally click on "Deploy" and see the magic happen.
You can check the logs to make sure that everything is working.
If the deployment was successful, click on the Node.js app service and in the setting panel scroll to "Networking" and you will find a public url. That's where your application resides. If you click on it, you should get a page that says "API is running".
You can always update the env variables, but always keep the variables with this value ${{db.VARIABLE}} or ${{redis.VARIABLE}} or ${{railway.VARIABLE}} the same!
Get free tutorials, AI news & special discounts.