Skip to content

Instantly share code, notes, and snippets.

@genevieve
Last active February 6, 2021 00:06
Show Gist options
  • Save genevieve/4cb0d91a58ecae5c66c894289a88de84 to your computer and use it in GitHub Desktop.
Save genevieve/4cb0d91a58ecae5c66c894289a88de84 to your computer and use it in GitHub Desktop.
Git Buildpack RFC

Git Support

Proposal

Introduce an (optional) Git buildpack into each language buildpack family. The buildpack will be charged with providing git metadata as build-time and run-time environment variables.

Motivation

Applications of any language may have a need for information extracted from git metadata. For example, the commit sha might be used as versioning information when building a Go binary or used when running a Rails application.

Implementation

A new git buildpack will be developed to detect whether the .git directory and BP_GIT_LOAD environment variable is present and set to true, and then read the directory to extract the following environment variables so that they can be included in the built image.

  • GIT_COMMIT_SHA

Detection Criteria

The buildpack will detect if:

  1. The .git directory is present
  2. The BP_GIT_LOAD environment variable is set to true.

Build Process

The build process of the buildpack will find the values for the expected environment variables and add them to a layer for use at launch.

Buildpack Order Grouping

The git buildpack can be added to each family buildpack or it can be added separately at the beginning of each ordering defined in a builder.

For example:

[[order]]

  [[order.group]]
    id = "paketo-buildpacks/go"
    version = "<version>"

  [[order.group]]
    id = "paketo-buildpacks/git"
    version = "<version>"
    optional = true

[[order]]

  [[order.group]]
    id = "paketo-buildpacks/ruby"
    version = "<version>"

  [[order.group]]
    id = "paketo-buildpacks/git"
    version = "<version>"
    optional = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment