Giter Site home page Giter Site logo

heroku-buildpack-run's Introduction

Heroku Buildpack: Run

Run custom commands during the build process.

Description

This buildpack allows specifying custom scripts or other commands that will be run during the build process. If any command exits with a non-zero status code, the build is aborted.

Usage

Using the buildpack-run.sh script

By default, the buildpack looks for a script named buildpack-run.sh in the root directory of your app. So, you can do the following:

echo -e '#!/bin/bash\necho "Hello World"' >buildpack-run.sh
chmod +x buildpack-run.sh
git add buildpack-run.sh && git commit
git push heroku master

The above example will print Hello World during the build.

Using the BUILDPACK_RUN config variable

Alternatively to using buildpack-run.sh, you can specify custom commands in the BUILDPACK_RUN config variable:

heroku config:set BUILDPACK_RUN='echo "Hello World"

The above example will print Hello World during the build.

You can also specify multiple commands by separating them with colons:

heroku config:set BUILDPACK_RUN='echo "Hello World":uname -a:./myscript.sh foo bar

In the above example, the buildpack will execute the following commands in sequence:

  1. echo "Hello World"
  2. uname -a
  3. ./myscript.sh foo bar

Loading config variables

By default, the app's config variables are only available as files in a specific directory in the build environment (see ENV_DIR below). You can load all these config variables as environment variables by setting the BUILDPACK_RUN_LOAD_CONFIG config variable:

heroku config:set BUILDPACK_RUN_LOAD_CONFIG=1

Now, all the app's config variables will be available to your commands as environment variables.

If you want to prevent certain config variables from being loaded as environment variables (for example, to prevent overwriting native environment variables), you can specify them in the BUILDPACK_RUN_LOAD_CONFIG_SKIP config variable (separated by colons):

heroku config:set BUILDPACK_RUN_LOAD_CONFIG_SKIP=FOO:BAR:BAZ

In the above example, the config variables named FOO, BAR, and BAZ will not be loaded as environment variables. Note that this may be especially useful for config variables like PATH that you might not want to overwrite in the build environment.

Default environment variables

The following special environment variables are always available to your commands:

  • BUILD_DIR: your app's root directory in the build environment
  • CACHE_DIR: directory that persists between builds and can be used as a cache
  • ENV_DIR: directory containing the app's config variables as files

License

Licensed under the MIT License. See LICENSE.md file.

heroku-buildpack-run's People

Contributors

weibeld avatar portersupport avatar nelsonjchen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.