A minimal example to deploy a rocket server on heroku
- Create a rust project and commit it to git.
cargo init
git init
- Create an app on heroku with
heroku create --buildpack emk/rust your-app
- Create a
Procfile
and add this line to itweb: ./target/release/your-rust-app-name
. E.g for this projectweb: ./target/release/heroku-rocket-minimal-example
- Push your app to heroku:
git push heroku master
- Check the logs with
heroku logs
. You should see an "Hello, World!". Great, the rust buildback is correctly building the project and running it.
- Add rocket as a dependency to your Cargo.toml file
rocket = "0.5.0-rc.2"
- Add routes to you project. See the
main.rs
for an example. - Be careful, you will need to bind to the port provided by Heroku thanks to env
PORT
and listen to bind to host0.0.0.0
(localhost won't work) - Deploy to heroku, wait a looooong time for the crates to compile.
- Go to you website adress, and you shoud get a 200 response with a welcoming message.
- If it goes wrong, you can check the logs with
heroku logs --tail