app roche

A cli to build serverless rust applications

6 releases

0.3.3 Feb 2, 2021
0.3.2 Feb 2, 2021
0.3.1 Jan 4, 2021
0.2.0 Jan 1, 2021
0.1.0 Dec 30, 2020

#1897 in Command line utilities

Apache-2.0 OR MIT

34KB
616 lines

roche

A cli for rapidly developing tide in containers.

introduction

Services built with Rust have some fantastic runtime qualities for serverless applications:

  • low resource footprint

  • quick startup time

  • zero garbage collection

However these things come with a trade off as build times are not ideal for rapid application development.

roche addresses this short coming by providing a function as a service pattern for tide that reduces build times to seconds and enables developers to focus on business logic allowing for the speedy delivery of blazing fast and energy efficient software.

It leverages the nesting feature of tide so all that is required to be developed is a handler while the application infrastructure is provided by prebuilt docker containers.

Once the base images are downloaded build times are around 5s for debug and 30s for Release.

Roche is intended to target knative environments but it can also be used to build standard docker containers.

See the Architecture page for details.

pre-reqs

  1. A docker or podman environment on your local machine.

  2. A local rust installation.

install

$ cargo install roche

usage

  1. make an empty folder and generate a function template
$ mkdir tide-faas
$ cd tide-faas
$ roche init

This creates a single function file that you can add functionality into.

pub fn handler() -> tide::Server<()> {    
    let mut api = tide::new();
    api.at("/").get(|_| async { Ok("Hello, World!") });
    api
}

That's all you need! Support for external libs will be added in the future probably through custome base images.

  1. Build the function image.
$ docker login 
$ roche build
# optionally you can provide an image name
$ roche build -t registry/namespace/devimagename:version
  1. If you would like to run the image use the standard docker commands
docker run -p 8080:8080 registry/namespace/devimagename:version
  1. For a release build run the following - These take slightly longer as they are compiled with the --release flag
$ roche release registry/namespace/imagename:version
  1. Deploy to your favourite container based FaaS platform.
$ docker push registry/namespace/imagename:version
# knative
$ kn service create roche-function --image registry/namespace/imagename:version
# ibmcloud
$ ibmcloud ce app create -n roche-function --image registry/namespace/imagename:version

notes

If you would like to run the build process as part of a CI/CD chain then the following command will generate a Dockerfile to ship in the same folder as function.rs.

$ roche gen

contribution

roche is an OPEN Open Source Project. This means that:

Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.

See the Contribution Guide for more details.

attributions

Icons made by Freepik from www.flaticon.com

Project generation features rely on the excellent cargo generator project

Insperation from Appsody (end of life)

Dependencies

~57MB
~1M SLoC