paketo-community / rust

Rust Cloud Native Buildpack
Apache License 2.0
27 stars 6 forks source link
cnb

docker.io/paketocommunity/rust

The Rust Cloud Native Buildpack provides a set of collaborating buildpacks that enable the building of a Rust-based application.

Included Buildpacks

tl;dr

You can build your app with two steps:

  1. Run pack build <image-name> -b docker.io/paketocommunity/rust. An image will be generated that you can run.
  2. Run the image with docker run -it <image-name>.

By default, the Rust buildpack will add process types for all of the binary projects in your workspace. You may optionally add a Procfile though if you need to customize the start command for your container.

What's Included

A Meta Buildpack

Included in this repo is a buildpack.toml that defines the Rust meta buildpack. It allows you to reference all of the Rust related CNBs in one convenient way & know that the order is set correctly.

This is available through a pre-built docker image on Docker Hub.

To use: pack build <image-name> -b docker.io/paketocommunity/rust

A Builder

In this repo is a sample example-builder.toml that you can use to create your own builder. We do not publish a builder, so if you'd like to use this route you must first create the builder.

To create the builder, just run pack builder create <published-to>/rust-builder --config example-builder.toml. For example, pack builder create paketocommunity/rust-builder --config example-builder.toml.

You can then build an app with it using pack build <image-name> --builder <published-to>/rust-builder.

The builder is configure to use the base build and run images, which is a reasonable mix of size and functionality. You may change the build and run images to use the full stack, which has a lot more libraries and tools installed but is quite a bit larger, or you can use the tiny build and run images which presents a very small container but doesn't even contain a shell, which can make debugging difficult.

To switch, swap the stack that you'd like to use in the builder file.

Example full stack:

[stack]
  id = "io.buildpacks.stacks.jammy"
  build-image = "docker.io/paketobuildpacks/build-jammy-base:latest"
  run-image = "docker.io/paketobuildpacks/run-jammy-base:latest"

Example tiny stack:

[stack]
  id = "io.buildpacks.stacks.jammy.tiny"
  build-image = "docker.io/paketobuildpacks/build-jammy-tiny"
  run-image = "docker.io/paketobuildpacks/run-jammy-tiny"

Tips

License

This buildpack is released under version 2.0 of the Apache License.