Deploy an Actix Rust Web App
Create a new PostgreSQL database on Render and copy the internal DB URL to use below.
Fork render-examples/actix_todo on GitHub.
Create a new Web Service on Render, and give Render’s GitHub app permission to access your new repo.
Rustfor the environment and use the following values during creation:
Here are the contents of the build script:
#!/usr/bin/env bash cargo build --release cargo install diesel_cli --no-default-features --features postgres diesel database setup
It’s simply executing commands needed to build and deploy an Actix web app on each push to your repo. It also uses the diesel CLI to run migrations before each deploy.
The internal connection string for the database you created above.
That’s it! Your web service will be live on your Render URL as soon as the build finishes.
Going forward, every push to your GitHub repo will automatically build your app and deploy it in production. If the build fails, Render will automatically stop the deploy process and the existing version of your app will keep running until the next successful deploy.
By default, Render uses the latest stable Rust toolchain, but you can specify a different toolchain by adding a file called
rust-toolchain at the root of your repo. It should contain a single line specifying the version. For example:
Render will automatically install the toolchain specified in this file and use it for your app.
You can also use the
RUST_TOOLCHAIN environment variable, which takes precedence over toolchain files.
cargo +nightly ..., the specified toolchain must already be installed. You can install new toolchains using
rustupas part of your build command.
Learn more about specifying a Rust toolchain.