Skip to content

Commit 0d177b8

Browse files
committed
Railpack doc
1 parent 55324ad commit 0d177b8

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

docs/concepts/Railpack.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: Railpack
3+
description: Defang will use Railpack to make an OCI-Compliant container image for your project.
4+
sidebar_position: 500
5+
---
6+
7+
# Railpack
8+
9+
[Railpack](https://railpack.com/) is a tool for building container images from source code with minimal configuration. It is the successor to [Nixpacks](https://nixpacks.com/) and incorporates several lessons learned from running Nixpacks in production at [Railway](https://railway.com/) over the years.
10+
11+
In Defang deployments, one of the most common points of failure is a missing or invalid Dockerfile that can’t produce OCI-compliant images. This is especially common when Dockerfile are generated by LLMs or created by users with limited Docker experience. Since integrating Railpack into Defang, if no Dockerfile is provided, we now automatically build a working image for you using Railpack.
12+
13+
## How to trigger a Defang Railpack deployment
14+
15+
When you run a Defang Railpack deployment you need 2 components:
16+
17+
1. A working application
18+
2. A valid compose file
19+
20+
Your compose file should not mention a Dockerfile.
21+
22+
For example,
23+
24+
```yaml
25+
# compose.yaml
26+
services:
27+
app:
28+
restart: unless-stopped
29+
build:
30+
context: .
31+
deploy:
32+
resources:
33+
reservations:
34+
cpus: "1.0"
35+
memory: 512M
36+
ports:
37+
- mode: ingress
38+
target: 3000
39+
published: 3000
40+
```
41+
42+
## Troubleshooting and tips
43+
44+
If the deployment fails, here are some things you can try.
45+
46+
### Railpack Detection
47+
48+
To allow Railpack to generate a build plan for your project, please structure it to include the following files, or rename existing ones to be compatible.
49+
50+
#### Node
51+
52+
Your project will be detected as a Node.js application if a `package.json` file exists in the root directory.
53+
54+
Here is an example of a Railpack ready NextJS project.
55+
Here is an example of a Railpack ready React Vite project.
56+
57+
#### Python
58+
59+
Your project will be detected as a Python application if any of these conditions are met:
60+
61+
- A main.py file exists in the root directory (If your main.py is named anything else)
62+
- A requirements.txt file exists
63+
- A pyproject.toml file exists
64+
- A Pipfile exists
65+
66+
Here is an example of a Railpack ready Flask project.
67+
Here is an example of a Railpack ready Django project.
68+
69+
#### Go
70+
71+
Your project will be detected as a Go application if any of these conditions are met:
72+
73+
- A go.mod file exists in the root directory
74+
- A go.work file exists in the root directory (Go workspaces)
75+
- A main.go file exists in the root directory
76+
77+
Here is an example of a Railpack ready Golang project.
78+
79+
#### PHP
80+
81+
Your project will be detected as a PHP application if any of these conditions are met:
82+
83+
- An index.php file exists in the root directory
84+
- A composer.json file exists in the root directory
85+
86+
#### Java
87+
88+
Your project will be detected as a Java application if any of these conditions are met:
89+
90+
- A gradlew (Gradle wrapper) file exists in the root directory (to create this, if you don’t have one, run gradle wrapper)
91+
- A pom.{xml,atom,clj,groovy,rb,scala,yaml,yml} file exists in the root directory
92+
93+
#### Ruby
94+
95+
Your project will be detected as a Ruby application if any of these conditions are met:
96+
97+
- A Gemfile file is present
98+
99+
#### Rust
100+
101+
Your project will be detected as a Rust application if any of these conditions are met:
102+
103+
- A Cargo.toml file is present
104+
105+
#### Elixir
106+
107+
Your project will be detected as a Elixir application if any of these conditions are met:
108+
109+
- A mix.exs file exists in the root directory.
110+
111+
#### Static Sites
112+
113+
Railpack can automatically build and setup a server for static sites that require no build steps. The [Caddy](https://caddyserver.com/) server is used as the underlying web server.
114+
115+
Your project will be automatically detected as a static site if any of these conditions are met:
116+
117+
- A Staticfile configuration file exists in the root directory
118+
- An index.html file exists in the root directory
119+
- A public directory exists
120+
- The RAILPACK_STATIC_FILE_ROOT environment variable is set

0 commit comments

Comments
 (0)