Detecting your application

Next, you will want to actually detect that the app your are building is a Ruby app. In order to do this, you will need to check for a Gemfile.

Replace exit 1 in the detect script with the following check:

if [[ ! -f Gemfile ]]; then
   exit 100

Your detect script should look like this:

#!/usr/bin/env bash
set -eo pipefail

if [[ ! -f Gemfile ]]; then
   exit 100

Next, rebuild your app with the updated buildpack:

pack build test-ruby-app --path ~/workspace/ruby-sample-app --buildpack ~/workspace/ruby-cnb

You should see the following output:

[detector] ======== Results ========
[detector] pass: [email protected]
[detector] Resolving plan... (try #1)
[detector] Success! (1)
[restorer] Cache '/cache': metadata not found, nothing to restore
[analyzer] Image '' not found
[builder] ---> Ruby Buildpack
[builder] Error: failed to build: exit status 1
ERROR: failed with status code: 7

Notice that detect now passes because there is a valid Gemfile in the Ruby app at ~/workspace/ruby-sample-app, but now build fails because it is currently written to error out.

You will also notice that ANALYZING now appears in the build output. This steps is part of the buildpack lifecycle that looks to see if any previous image builds have layers that the buildpack can re-use. We will get into this topic in more detail later.

Next Step

Last modified by Javier Romero