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
exit 1 in the
detect script with the following check:
if [[ ! -f Gemfile ]]; then exit 100 fi
detect script should look like this:
#!/usr/bin/env bash set -eo pipefail if [[ ! -f Gemfile ]]; then exit 100 fi
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:
===> DETECTING [detector] ======== Results ======== [detector] pass: [email protected] [detector] Resolving plan... (try #1) [detector] Success! (1) ===> RESTORING [restorer] Cache '/cache': metadata not found, nothing to restore ===> ANALYZING [analyzer] Image 'index.docker.io/library/test-ruby-app:latest' not found ===> BUILDING [builder] ---> Ruby Buildpack [builder] Error: failed to build: exit status 1 ERROR: failed with status code: 7
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.