Skip to content

Commit a2c5304

Browse files
mtwicheltomarra
andauthored
docs: add railway deployment docs (#1527)
Co-authored-by: Tom Arra <[email protected]>
1 parent e4cd75e commit a2c5304

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

.github/cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"hotreload",
2222
"intelli",
2323
"sigint",
24-
"devserver"
24+
"devserver",
25+
"nixpacks"
2526
],
2627
"ignoreWords": ["cleverapps", "WORKDIR"]
2728
}

docs/docs/deploy/railway.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
sidebar_position: 5
3+
title: 🛤️ Railway
4+
---
5+
6+
# Railway 🛤️
7+
8+
[Railway](https://railway.app) is a cloud platform that can build, deploy, and monitor your HTTP applications (like APIs made with Dart Frog) with minimal setup. It embraces private networks so you can link databases with other services easily and securely without needing much knowledge of network security. It also features:
9+
10+
- Secret management
11+
- Autoscaling (both vertically and horizontally), as well as sleeping services when not in use.
12+
- Auto deployment from GitHub
13+
- Usage based pricing
14+
- Hundreds of templates for quickly deploying ready-to-use software
15+
- Health checks, instant rollbacks, environments, and more
16+
17+
This guide will show you how to auto-build-and-deploy to Railway using it's integrated build system. However, Railway is also able to deploy pre-built Docker images. You could also build your application in an external system (like GitHub Actions) and [deploy to Railway with that image](https://docs.railway.app/overview/the-basics#services).
18+
19+
## Prerequisites
20+
21+
Before you get started, if you don't already have these, you'll need to create:
22+
23+
- A [free Railway account](https://railway.app)
24+
- A [Railway project](https://railway.app/dashboard)
25+
26+
:::caution
27+
At the time of writing, Railway has a free tier that allows you to experiment with their platform. However, you are responsible for any costs that may incur with this tutorial. For more details, see the [Railway Pricing Page](https://railway.app/pricing).
28+
:::
29+
30+
In addition, your Dart Frog project must include `dart_frog_cli` in your `dev_dependencies`. This is so that you can run `dart_frog build` without needing to instal the cli. Just add it like this:
31+
32+
```yaml
33+
dev_dependencies:
34+
dart_frog_cli:
35+
```
36+
37+
## Deploying
38+
39+
### 1. Create the Service
40+
41+
To start, in your Railway project, [create a new service connected to your repository](https://docs.railway.app/guides/services#creating-a-service). You'll have to connect to your GitHub account to select the repository.
42+
43+
:::tip
44+
If your repository is a _monorepo_ and your Dart Frog project is not the project's root directory, you can specify it's directory in the `Add Root Directory` setting under the `Source Repo` settings.
45+
:::
46+
47+
### 2. Configure the Settings
48+
49+
Scroll to the `Build` section. Adjust these settings: - For `Providers`, Railway should have already detected `Dart` as the language. If it hasn't, add it using the plus button. - For `Custom Build Command`, enter the following command, then click the checkmark to save the setting.
50+
51+
```bash
52+
dart run dart_frog_cli:dart_frog build && dart compile exe build/bin/server.dart -o build/bin/server
53+
```
54+
55+
Scroll to the `Deploy` section. For `Custom Start Command`, set the value the following command, then click the checkmark to save the setting.
56+
57+
```bash
58+
./build/bin/server
59+
```
60+
61+
:::note
62+
There are a bunch of other settings to further configure your deployments. For more information, see the [Railway Deployment Guides](https://docs.railway.app/guides/deployments).
63+
:::
64+
65+
### 3. Deploy
66+
67+
On the main area to the left of configuration, you should see a dialog saying _Apply X Changes_ with a deploy button. Click `Deploy`. After a few minutes, you deployment should finish successfully! 🎉
68+
69+
:::tip
70+
If you are building an external service, such as an API or website, be sure to enable a public domain under the `Networking` settings. For more info, see the [Public Networking Guide](https://docs.railway.app/guides/public-networking).
71+
:::
72+
73+
## Additional Resources
74+
75+
- [Railway Docs](https://docs.railway.app)
76+
- [Logging and Monitoring Docs](https://docs.railway.app/guides/logs)
77+
- [Configuring Health Checks](https://docs.railway.app/guides/healthchecks-and-restarts)
78+
- [Connecting Databases](https://docs.railway.app/guides/databases)
79+
- [Nixpacks Docs (used behind the scenes)](https://nixpacks.com/docs)

0 commit comments

Comments
 (0)