Skip to content

fnichol/rocketry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rocketry - A Sample Rust/Rocket Application with Habitat Plan

Build Status license

This is a small sample web application written in Rust using the Rocket project and includes a Habitat Plan which can build this into a package.

  • It takes one optional command line argument which is a port number to use, otherwise defaulting to 8000 so that it can run without root permissions.
  • The simple Rocket application is setup to run in "production" mode and will skip all Rocket.toml and environment variables. This isn't a requirement per se, but illustrative of how Habitat can manage these details dynamically on behalf of a service.
  • The Habitat Plan builds a statically linked, relocatable binary for its package using a musl target.

Pre-requisites

This project requires using a Nightly version of Rust, which you can install using rustup with:

curl https://sh.rustup.rs -sSf | sh
rustup install nightly
cd rocketry
rustup override set nightly

Building

Development

Building this project should be fairly straight forward as there aren't any system dependencies required:

cargo build

To compile a production-ready binary, you can add the --release flag:

cargo build --release

Habitat

You can follow the instructions on the Habitat website to get set up and then, from the git checkout directory, run:

hab pkg build .

This will produce a Habitat package in the ./results/ directory.

Running

Development

You can either use cargo run to try it out:

# You can use -- as the delimter for your program to recieve arguments
cargo run -- 9000

Or run the binary directly which is in the ./target/ directory. Assuming it's not a release build:

./target/debug/rocketry

Or to override the default listen port:

./target/debug/rocketry 9000

Habitat

To enter a quick environment suitable for trying out your Habitat package, you can enter an interactive Studio with:

hab studio enter

and either rebuild your project (with build .) or install the package you made with:

hab install ./results/*-rocketry-*.hart

Finally, start the service with:

hab start <yourorigin>/rocketry

where <yourorigin> is your origin name you chose when you set up Habitat on your system.

About

This is a small sample web application written in Rust using the Rocket project and includes a Habitat plan which can build this into a package.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published