• Stars
    star
    513
  • Rank 86,178 (Top 2 %)
  • Language
    Shell
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A buildpack for Rust applications on Heroku, with full support for Rustup, cargo and build caching.

Heroku buildpack for Rust

Build Status

This is a Heroku buildpack for Rust with support for cargo and rustup. Features include:

  • Caching of builds between deployments.
  • Automatic updates to the latest stable Rust by default.
  • Optional pinning of Rust to a specific version.
  • Support for export so that other buildpacks can access the Rust toolchain.
  • Support for compiling Rust-based extensions for projects written in other languages.

Example projects

Here are several example projects:

Using this buildpack

To deploy an application to Heroku, we recommend installing the Heroku CLI.

If you're creating a new Heroku application, cd to the directory containing your code, and run:

heroku create --buildpack emk/rust

This will only work if your application has a Cargo.toml and uses git. If you want to set a particular name for application, see heroku create --help first.

To use this as the buildpack for an existing application, run:

heroku buildpacks:set emk/rust

You will also need to create a Procfile pointing to the release version of your application, and commit it to git:

web: ./target/release/hello

...where hello is the name of your binary.

To deploy your application, run:

git push heroku master

Running Diesel migrations during the release phase

This will install the diesel CLI at build time and make it available in your dyno. Migrations will run whenever a new version of your app is released. Add the following line to your RustConfig

RUST_INSTALL_DIESEL=1

and this one to your Procfile

release: ./target/release/diesel migration run

Specifying which version of Rust to use

By default, your application will be built using the latest stable Rust. Normally, this is pretty safe: New stable Rust releases have excellent backwards compatibility.

But you may wish to use nightly Rust or to lock your Rust version to a known-good configuration for more reproducible builds. To specify a specific version of the toolchain, use a rust-toolchain file in the format rustup uses.

Note: if you previously specified a VERSION variable in RustConfig, that will continue to work, and will override a rust-toolchain file.

Combining with other buildpacks

If you have a project which combines both Rust and another programming language, you can insert this buildpack before your existing one as follows:

heroku buildpacks:add --index 1 emk/rust

If you have a valid Cargo.toml in your project, this is all you need to do. The Rust buildpack will run first, and your existing buildpack will run second.

But if you only need Rust to build a particular Ruby gem, and you have no top-level Cargo.toml file, you'll need to let the buildpack know to skip the build stage. You can do this by adding the following line to RustConfig:

RUST_SKIP_BUILD=1

Customizing build flags

If you want to change the cargo build command, you can set the RUST_CARGO_BUILD_FLAGS variable inside the RustConfig file.

RUST_CARGO_BUILD_FLAGS="--release -p some_package --bin some_exe --bin some_bin_2"

The default value of RUST_CARGO_BUILD_FLAGS is --release. If the variable is not set in RustConfig, the default value will be used to build the project.

Using the edge version of the buildpack

The emk/rust buildpack from the Heroku Registry contains the latest stable version of the buildpack. If you'd like to use the latest buildpack code from this Github repository, you can set your buildpack to the Github URL:

heroku buildpacks:set https://github.com/emk/heroku-buildpack-rust

Development notes

If you need to tweak this buildpack, the following information may help.

Testing with Docker

To test changes to the buildpack using the included docker-compose-test.yml, run:

./test_buildpack

Then make sure there are no Rust-related *.so files getting linked:

ldd heroku-rust-cargo-hello/target/release/hello

This uses the Docker image heroku/cedar, which allows us to test in an official Cedar-like environment.

We also run this test automatically on Travis CI.

More Repositories

1

rust-musl-builder

Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.
Dockerfile
1,451
star
2

subtitles-rs

Use SRT subtitle files to study foreign languages (in progress)
Rust
283
star
3

toyos-rs

Just hacking around on a toy Rust-based on based on the blog posts at http://blog.phil-opp.com/
Rust
85
star
4

sinatra-url-for

Construct absolute paths and full URLs to actions in a Sinatra application
Ruby
60
star
5

rust-streaming

EXPERIMENTAL: Various hacks for zero-allocation stream parsing in Rust.
Rust
58
star
6

heroku-rust-cargo-hello

Simple Rust webserver built using Cargo, deployable to Heroku.
Rust
48
star
7

rust-buildpack-example-actix

Example Rust application for Heroku
Rust
40
star
8

duktape-rs

Rust wrapper for Duktape, a lightweight, embedded JavaScript interpreter.
Rust
35
star
9

rust-uchardet

Rust wrapper for the uchardet character encoding detection library
Rust
24
star
10

eshell

A complete OS command-shell, written entirely in Emacs Lisp.
Emacs Lisp
24
star
11

haskell-probability-monads

Composable probability monads in Haskell.
Haskell
22
star
12

credentials

Fetch secure credentials from multiple backends (environment, Vault, etc.) using Rust
Rust
20
star
13

rdf-agraph

Ruby AllegroGraph repository adapter for RDF.rb
Ruby
17
star
14

compose_yml

WIP: Read and write docker-compose.yml files using Rust
Rust
16
star
15

electron-test

OUT OF DATE! A fully buzzword-compliant experimental project: Electron, TypeScript, React, Redux, WebPack and Rust. It compiles and runs!
TypeScript
16
star
16

safe_erb

Automatically detect improperly escaped text in ERB templates
Ruby
16
star
17

pstsdk

Portability patches for Microsoft's pstsdk library, which reads PST-format email archives. Master branch tracks SVN; other branches contain patches.
C
15
star
18

rust-buildpack-example-rocket

Buildback example for Rust Rocket framework
Rust
14
star
19

node-feedhose

Experimental: Feedhose instant RSS protocol support for Node.js
JavaScript
13
star
20

rust-cld2

Rust wrapper for the cld2 language detection library.
Rust
12
star
21

accessors

(WIP) Getters and setters for Rust using macros 1.1
Rust
11
star
22

subtitles-rs-old

THIS IS AN ARCHIVE OF AN OLDER PROJECT, SEE subtitles-rs FOR THE CURRENT VERSION.
11
star
23

sinasi

Sinasi is not a SproutCore IDE: A SproutCore port of Rinari, for use with Emacs.
Emacs Lisp
11
star
24

resource_monitor

Detect when your Dockerized Rust application is low on memory
Rust
10
star
25

halyard

2D/3D multimedia engine scripted in Scheme
C++
9
star
26

wasm-bloat

WORK IN PROGRESS: wasm size analysis tools, may not go anywhere depending on schedule
Rust
8
star
27

cesu8-rs

Rust library which converts between UTF-8 and CESU-8 encodings.
Rust
8
star
28

xmonad-config

My Xmonad window manager configuration.
Haskell
8
star
29

rust-slow-iteration-demo

Trying to make non-copying iterators work over streaming input.
Rust
6
star
30

lexique-experiments

Experiments with the Lexique French frequency database
Python
6
star
31

blogitr

(Work in progress.) A blog storage engine based on git.
Ruby
5
star
32

mongoid_attachment

WORK IN PROGRESS: Lightweight Mongoid attachments using GridFS
Ruby
5
star
33

mongoid_references

references_one and references_many for Mongoid: Forward references through BSON::ObjectID
Ruby
4
star
34

elisp

My personal Emacs configuration
Emacs Lisp
3
star
35

hierogloss

Markdown extensions for hieroglyphic glosses (and BBCode output for forums)
Ruby
3
star
36

filtered_column_haskell_macro

A Mephisto port of Tom Moertel's typo:haskell plugin
2
star
37

wave-pick-several

An approval-voting gadget for use with Google Wave
Java
2
star
38

abort_on_panic-rs

Rust library to intercept panic! from unsafe locations and abort the process (for use with C FFI callbacks)
Rust
2
star
39

experimental-coq-proofs

Messing around with the Coq proof assistant
Coq
2
star
40

word-puzzler

WORK IN PROGRESS: Toolkit for solving various sorts of word puzzles.
Rust
2
star
41

buglinky

A Wave bot which turns bug numbers into links
Java
2
star
42

mongoid_attr_accessible

attr_accessible access control for Mongoid (replaces :accessible)
Ruby
2
star
43

ibus-ancient

ibus keyboards and input methods for ancient languages (prerelease).
Shell
2
star
44

heroku-rust-hello

A sample Rust application for use with emk/heroku-buildpack-rust. Uses Rustful and runs on Heroku.
Rust
2
star
45

jbob-rs

WIP: A Rust port of the J-Bob proof assistant from https://the-little-prover.github.io/
Scheme
2
star
46

pyjamas

Pyjamas is a Web Toolkit Widget set, AJAX library and python-to-javascript compiler.
Python
2
star
47

FactorioNuclearVehicles

An idea for a Factorio mod. This was fun to write!
Lua
1
star
48

snappy_framed-rs

Read and write the Snappy "framed" compression format from Rust (modest compression, very fast).
Rust
1
star
49

wave-protocol

hg-git mirror of Google's FedOne Wave server
1
star
50

cld2

Git mirror of cld2 language detection library from https://code.google.com/p/cld2/ (minus the file test_shuffle_1000_48_666.utf8)
C++
1
star
51

langforums

Temporary forum prototype to replace an existing site. UNMAINTED, RUNNING NOWHERE, WOULD NEED SECURITY UPDATES.
Ruby
1
star
52

uscheme

A random personal hack: A tiny fragment of Scheme in Haskell
Haskell
1
star
53

french-nlp-vagrant

A Vagrant VM which runs French natural language processing tools / Une machine virtuelle pour le traitement du langage naturel.
Shell
1
star
54

cstore

Really dodgy experiments with Go, Redis, and distributed SHA256 content-addressable storage.
Go
1
star
55

dribble-rs

Test your implementations of Rust's Read and Write traits by passing data in small, randomly-sized chunks.
Rust
1
star