The sections below describe the expected behavior of the buildpack. The codebase must be updated if a difference exists between this contract and actual behavior. Either the code needs to change to suit the contract, or the contract needs to be updated. If you see a difference, please open an issue with a minimal application that reproduces the problem.
If you need application-specific support, you can ask on an official Heroku support channel or Stack Overflow.
The detect phase determines whether or not this buildpack can execute. It can also be used to request additional functionality via requiring behavior from other buildpacks.
- Node version
- Given a
package.jsonfile in the root of the application theheroku/nodejs-enginebuildpack will be required. See README for behavior
- Given a
- Yarn version
- Given a
yarn.lockfile in the root of the application theheroku/nodejs-yarnbuildpack will be required. See README for behavior
- Given a
- Java version
- Given a
Gemfile.lockfile that specifies jruby theheroku/jvmbuildpack will be required. See README for behavior
- Given a
- Ruby version
- Given a
Gemfile.lockthis buildpack will execute the Ruby build contract below.
- Given a
Once an application has passed the detect phase, the build phase will execute to prepare the application to run.
- Ruby version:
- Given a
Gemfile.lockwith an explicit Ruby version, we will install that Ruby version. - Given a
Gemfile.lockwithout an explicit Ruby version, we will install a default Ruby version.- When the default value changes, applications without an explicit Ruby version will receive the updated version on their next deployment.
- We will reinstall Ruby if your distribution name or version (operating system) changes.
- We will reinstall Ruby if your CPU architecture (i.e. amd64) changes.
- Given a
- Bundler version:
- Given a
Gemfile.lockwith an explicit Bundler version we will install that bundler version. - Given a
Gemfile.lockwithout an explicit Bundler version we will install a default Ruby version.
- Given a
- Ruby Dependencies:
- We will always run
bundle install. - We will always run
bundle cleanafter a successfulbundle install. - We will always cache the contents of your gem dependencies.
- We will always invalidate the dependency cache if your distribution name or version (operating system) changes.
- We will always invalidate the dependency cache if your CPU architecture (i.e. amd64) changes.
- We will always invalidate the dependency cache if your Ruby version changes.
- We may invalidate the dependency cache if there was a bug in a prior buildpack version that needs to be fixed.
- We will delete the rubygems
cachedirectory that holds the original<gem-name>.gemfiles after installation. This step reduces final image size and does not impact futurebundle installinstallation performance.
- We will always run
- Gem specific behavior - We will parse your
Gemfile.lockto determine what dependencies your app need for use in specializing your install behavior (i.e. Rails 5 versus Rails 4). The inclusion of these gems may trigger different behavior:railties
- Applications without
rakein theGemfile.lockor aRakefilevariant MAY skip rake task detection. - Rake execution - We will determine what rake tasks are runnable via the output of
rake -Pagainst your application.- We will always abort the build if the
rake -ptask fails. - We will always run
rake assets:precompileon your app if that task exists for your application.- We will always skip this
assets:precompiletask if a manifest file exists in thepublic/assetsfolder that indicates precompiled assets are checked into git..sprockets-manifest-*.jsonmanifest-*.json
- We will abort your build if the
rake assets:precompiletask fails. - We will run
rake assets:cleanon your app.- We will cache the contents of
public/assetsifassets:cleanexists on your application. - We will cache asset "fragments" directories if the
assets:cleanexists on the system. - We will limit or prune the size of the asset cache in
tmp/cache/assetsto 100 MiB.- We will delete the least recently used (LRU) files first. Detected via file mtime.
- We will cache the contents of
- We will always skip this
- We will always abort the build if the
- Process types:
- Given an application with the
railtiesgem:- We will default the web process to
bin/rails serverwhile specifying--port $PORT,--environment $RAILS_ENV"and an IPv6 host with--binding "::"(equivalent of IPv4 host0.0.0.0). Use theProcfileto override this default.
- We will default the web process to
- If
railtiesgem is not found butrackgem is present and aconfig.rufile exists on root:- We will default the web process to
rackupwhile specifying--port $PORTand IPv6 host with--host "::"(equivalent of IPv4 host0.0.0.0). Use theProcfileto override this default. .
- We will default the web process to
- Given an application with the
- Environment variable defaults - We will set a default for the following environment variables:
JRUBY_OPTS="-Xcompile.invokedynamic=false"- Invoke dynamic is a feature of the JVM intended to enhance support for dynamicaly typed languages (such as Ruby). This caused issues with Physion Passenger 4.0.16 and was disabled details. You can override this value.RACK_ENV=${RACK_ENV:-"production"}- An environment variable that may affect the behavior of Rack based webservers and webapps. You can override this value.RAILS_ENV=${RAILS_ENV:-"production"}- A value used by all Rails apps. By default, Rails ships with three environments:development,test,andproduction. We recommend all apps being deployed to useproductionand recommend against using a custom env such asstagingdetails. You can override this value.SECRET_KEY_BASE=${SECRET_KEY_BASE:-<generate a secret key>}- In Rails 4.1+ apps a value is needed to generate cryptographic tokens used for a variety of things. Notably this value is used in generating user sessions so modifying it between builds will have the effect of logging out all users. This buildpack provides a default generated value. You can override this value.BUNDLE_WITHOUT=development:test- Tells bundler to not installdevelopmentortestgroups duringbundle install. You can override this value.
- Environment variables modified - In addition to the default list this is a list of environment variables that the buildpack modifies:
BUNDLE_FROZEN=1- RequiresGemfile.lockto be in sync with the currentGemfile.BUNDLE_GEMFILE=<app-dir>/Gemfile- Tells bundler where to find theGemfile.DISABLE_SPRING="1"- Spring is a library that attempts to cache application state by forking and manipulating processes with the goal of decreasing development boot time. Disabling it in production removes significant problems details.GEM_PATH=<bundle-path-dir>- Tells Ruby where gems are located.MALLOC_ARENA_MAX=2- Controls glibc memory allocation behavior with the goal of decreasing overall memory allocated by Ruby details.PATH- Various executables are installed and thePATHenv var will be modified so they can be executed at the system level. This is mostly done via interfaces provided bylibcnband CNB layers rather than directly.- Executables in the application
bindirectory will take precedence over gem installed executables. Note that some commands likebundle execmay alter thePATHto change this order. - Executables from gems will take precedence over executables that ship with Ruby (for example
rakeinstalled frombundle installshould be loaded beforerakethat comes with the compiled Ruby binary).
- Executables in the application
RAILS_LOG_TO_STDOUT="enabled"- Sets the default logging target to STDOUT for Rails 5+ apps. detailsRAILS_SERVE_STATIC_FILES="enabled"- Enables theActionDispatch::Staticmiddleware for Rails 5+ apps so that static files such as those inpublic/assetsare served by the Ruby webserver such as Puma details.PUMA_PERSISTENT_TIMEOUT=95- Sets an idle timeout value that aligns with Heroku's Router 2.0. This value is automatically adopted by Puma 7+ applications. Applications using Puma 6 or prior can use it manually in theirconfig/puma.rb. Applications using a different web server can use it as a stable source of suggested idle timeout information.