Deploying Rust Projects
Zeabur supports most types of Rust applications - by default, it finds and runs the executable file automatically; however, you can also specify which executable file to run in the “Service Name” field.
If you don't currently have a Rust project and want to try it, feel free to fork zeabur/axum-template (opens in a new tab) to your GitHub account and deploy it on Zeabur.
Supported project types
- Single-executable projects: Rust project with just one
src/main.rs
entry point. Zeabur finds the only executable artifact in thetarget/release
directory. Also, it is acceptable to fill in the “Service Name” field with the artifact filename to execute to ensure Zeabur runs what you want. - Multi-executable projects: Rust project with two or more entry points, including
src/main.rs
and other files insrc/bin
. You may need to fill in the “Service Name” field with the artifact filename to execute. - Cargo Workspace mono-repo: Rust project with multiple crates. You may need to fill in the “Service Name” field with the artifact filename to execute.
When the executable filename you wrote did not hit, Zeabur will try to find the executable file automatically.
Zeabur scans all the files in target/release
and runs the first executable file it found.
Since this pattern is easy to guess wrong in complex scenarios (such as Multi-executable projects
and Cargo Workspace mono-repo), it is recommended that you fill in the correct “Service Name”.
Refer to “Find artifact filename” for more information.
Find artifact filename
The artifact can be found in the directory target/release
of your project. To do this:
-
You need the Rust toolchain to compile the project. Download it on rust-lang.org (opens in a new tab).
-
Clone the project you want to deploy and change to the project directory.
-
Run
cargo build --release
to compile the project.$ cargo run --release Compiling zeabur v0.1.0 (/project) Finished release [optimized] target(s) in 0.65s Running `target/release/zeabur`
-
Find the line starting with “Running”, and we pick the base (trailing) name of the following path (
target/release/zeabur
). For this case, it iszeabur
. -
Fill
zeabur
to the “Service Name” field.
Copy other files
If your application depends on other files or directories in the source code repository in addition to the executable file. For example:
*public
|`-- public <-- Your application depends on this folder
|``-- src
|-- main.rs
|``-- Cargo.toml
|``-- Cargo.lock
`-- config.toml <-- Your application depends on this file
Zeabur allows you preserving them with the file .zeabur-preserve
. Fill the file
and directories you want to preserve to this file. The directories can optionally end with /
.
An example is as follows:
public/
config.toml
Technical details and considerations
- The Rust image is based on Multi-Stage Build, and the runtime uses
docker.io/library/debian:bookworm-slim
as the base image. Some dynamic libraries may not work properly in the runtime due to the lack of some specific packages. For this case, please open a ticket about adding support for this package.- We currently install
openssl
in the runtime environment.
- We currently install
- No
root
at runtime. Bring your Dockerfile if you need it. - We use
lld
to speed up compilation. If your project does not supportlld
, we recommend that you specifyconfig.toml
in your project to call the standardld
. If you want to use a non-built-in linker such asmold
, you need to write your own Dockerfile. - We use
cargo-chef
to maximize the cache of build layers. If you encounter any incompatible problems, please report them to Zeabur or upstreamLukeMathWalker/cargo-chef
(opens in a new tab).