GithubHelp home page GithubHelp logo

hugo / heroku-buildpack-rust Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hoverbear/heroku-buildpack-rust

0.0 2.0 0.0 22 KB

A Rust buildpack for Heroku!

Home Page: https://rust-buildpack-test.herokuapp.com/

Makefile 6.21% Shell 93.79%

heroku-buildpack-rust's Introduction

heroku-buildpack-rust

Build Status

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.

Configuration

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 <[email protected]>"]

[dependencies]
iron = "*"

[target.heroku]
version = "nightly"

Instructions

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" > Procfile

Example App

After 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 master

Heroku should then build your application. Finally, you may need to start your application's web dyno with:

heroku ps:scale web=1

Now you can visit https://$APP.herokuapp.com/ and see your application!

Testing

If you have Docker, you can test this buildpack by doing the following:

make

The Makefile defines how to pull down the testrunner and build the appropriate docker container, then test the buildpack.

heroku-buildpack-rust's People

Contributors

homu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.