Skip to content

Commit e12f5ea

Browse files
authored
Merge pull request #998 from feldroy/add-railway-deployment-docs
Add Railway deployment docs
2 parents a502c49 + b3e4f64 commit e12f5ea

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

docs/deployment/index.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Deployment
2+
3+
Air applications can be deployed in several ways. We provide detailed examples for containerization and Kubernetes deployment, and have successfully deployed Air apps on various hosting platforms.
4+
5+
## Examples
6+
7+
* [Containerizing an Air application](https://github.com/feldroy/air/tree/main/examples/containerize)
8+
* [Deploying an Air application to Kubernetes](https://github.com/feldroy/air/tree/main/examples/deployment/k8s)
9+
10+
## Hosting Platforms
11+
12+
We have experience deploying Air on the following hosting platforms. If you're using these services, please consider using our referral links - they help sustain the Air project! 💚
13+
14+
### Railway
15+
16+
* [Our Railway referral link to get $20 in Railway credit](https://railway.com?referralCode=5EX8pI)
17+
* [Example Railway config for Air](railway.md)
18+
19+
### Vultr
20+
21+
* [Our Vultr link to get $300 of Vultr credit](https://www.vultr.com/?ref=9686150)
22+
23+
### FastAPI Cloud
24+
25+
* Not open to the public yet, but you can join the [FastAPI Cloud waitlist](https://fastapicloud.com/)
26+
27+
## Contributing
28+
29+
Have you deployed Air on other platforms? We'd love to hear about your experience! Consider contributing deployment guides or examples back to the [Air repository](https://github.com/feldroy/air) to help the community.

docs/deployment/railway.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Deploying Air on Railway
2+
3+
Railway is a platform for deploying web applications with automatic scaling, built-in databases, and zero-config deployments. This guide shows how to deploy an Air application to Railway using Nixpacks for builds and Hypercorn for serving.
4+
5+
## Prerequisites
6+
7+
- An Air project with a `main.py` file containing your app.
8+
- A Railway account and project connected to your Git repository.
9+
- (Optional) Railway's PostgreSQL plugin if your app uses a database.
10+
11+
Railway automatically detects Python projects and uses Nixpacks to build them. It provides a `$PORT` environment variable for binding your server.
12+
13+
## Add hypercorn to the dependency list
14+
15+
We use Hypercorn instead of Uvicorn here because one of the prerequisites for deploying Starlette apps to Railway is Hypercorn as a dependency in the pyproject.toml. When using `uv`, add it to your base packages in `pyproject.toml` thus:
16+
17+
```sh
18+
uv add hypercorn
19+
```
20+
21+
If using `pip` or `uv pip`, you'll need to add hypercorn to whatever file stores your dependency list (often this is `requirements.txt`).
22+
23+
## Basic Configuration
24+
25+
Create a `railway.json` file in your project root:
26+
27+
```json
28+
{
29+
"$schema": "https://railway.app/railway.schema.json",
30+
"build": {
31+
"builder": "NIXPACKS"
32+
},
33+
"deploy": {
34+
"startCommand": "uv run hypercorn main:app --bind \"[::]:$PORT\""
35+
}
36+
}
37+
```
38+
39+
Tips:
40+
41+
- Commit your uv.lock file to the repo. Don't .gitignore or .railwayignore it.
42+
- Use hypercorn because Railway insists on using it instead of uvicorn.

mkdocs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ nav:
6868
- sprint/index.md
6969
- Source Examples: sprint/src_examples.md
7070

71+
- Deployment: deployment/index.md
72+
7173
theme:
7274
name: material
7375
features:

0 commit comments

Comments
 (0)