Deprecated, please don't use this. It's far, far too old.
Features:
- Cached
multirust, Rust toolchain. - Caching of previous build artifacts to (potentially dramatically) speed up similar builds.
- Configurable version selection inside of the
Cargo.toml, or by specifying the$RUST_VERSIONenvironment variable.
You can use any override you would pass multirust for this buildpack.
We currently (ab)use the cargo's "target" feature to set the version desired.
Unfortunately because of this there are sometimes (harmless) cargo warnings
about an unused value in the toml file.
Example:
[package]
name = "foo"
version = "0.1.0"
authors = ["Andrew Hobden <andrew@hoverbear.org>"]
[dependencies]
iron = "*"
[target.heroku]
version = "nightly"APP="rust-buildpack-test" && \
cargo new --bin $APP && \
cd $APP && \
git init && \
heroku create $APP --buildpack https://github.com/Hoverbear/heroku-buildpack-rust && \
echo "web: target/release/$APP" > ProcfileAfter following the instructions above, in Cargo.toml add:
[dependencies]
iron = "*"In src/main.rs let's use a simple iron demo:
extern crate iron;
use iron::prelude::*;
use iron::status;
use std::env;
fn main() {
fn hello_world(_: &mut Request) -> IronResult<Response> {
Ok(Response::with((status::Ok, "Hello World!")))
}
let url = format!("0.0.0.0:{}", env::var("PORT").unwrap());
println!("Binding on {:?}", url);
Iron::new(hello_world).http(&url[..]).unwrap();
println!("Bound on {:?}", url);
}Now the following steps:
git add src/main.rs Cargo.toml Procfile && \
git commit -m "Init" && \
git push heroku masterHeroku should then build your application. Finally, you may need to start your
application's web dyno with:
heroku ps:scale web=1Now you can visit https://$APP.herokuapp.com/
and see your application!
If you have Docker, you can test this buildpack by doing the following:
makeThe Makefile defines how to pull down the testrunner and build the appropriate
docker container, then test the buildpack.