Giter Site home page Giter Site logo

bundle-install's Introduction

bundle-install

gcr.io/paketo-buildpacks/bundle-install

A Cloud Native Buildpack to install gems from a Gemfile

This will be providing gems.

bundle-install's People

Contributors

arjun024 avatar ctrox avatar dependabot[bot] avatar dmikusa avatar foresteckhardt avatar joshzarrabi avatar kvedurmu avatar paketo-bot avatar robdimsdale avatar ryanmoran avatar sophiewigmore avatar thitch97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bundle-install's Issues

Buildpack doesn't support major.minor version specified for Ruby in the Gemfile

What happened?

Please provide some details about the task you are trying to accomplish and
what went wrong.

  • What were you attempting to do?
    I was trying to build a ruby application with a gemfile that specifies major.minor for Ruby.

  • What did you expect to happen?
    I expected the buildpack to build the image with the correct mri version.

  • What was the actual behavior? Please provide log output, if possible.
    Instead, it used the latest ruby version

===> BUILDING
Paketo MRI Buildpack 0.0.164
  Resolving MRI version
    Candidate version sources (in priority order):
      <unknown> -> "*"
      <unknown> -> "*"
    Selected MRI version (using <unknown>): 2.7.2
  Executing build process
    Installing MRI 2.7.2
      Completed in 1.005s
  Configuring environment
    GEM_PATH -> "/home/cnb/.gem/ruby/2.7.0:/layers/paketo-buildpacks_mri/mri/lib/ruby/gems/2.7.0"

It looks like the code forces you to specify a patch when it should be able to accept major.minor and then decide which of the available mri version patches to use.

quotes := `["']`
versionOperators := `~>|<|>|<=|>=|=`
versionNumber := `\d+\.\d+\.\d+`
expression := fmt.Sprintf(`ruby %s((%s)?\s*%s)%s`, quotes, versionOperators, versionNumber, quotes)

Build Configuration

Please provide some details about your build configuration.

  • What platform (pack, kpack, tekton buildpacks plugin, etc.) are you using? Please include a version.

  • What buildpacks are you using? Please include versions.
    ruby 0.2.0

  • What builder are you using? If custom, can you provide the output from pack inspect-builder <builder>?

  • Can you provide a sample app or relevant configuration (buildpack.yml,
    nginx.conf, etc.)?

Checklist

Please confirm the following:

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.

The buildpack should error if the Gemfile and Gemfile.lock are out of sync.

I updated the puma gem in my Gemfile but didn't update the Gemfile.lock and the buildpack reused the cache without erroring:

Paketo Bundle Install Buildpack 0.0.59
  Reusing cached layer /layers/paketo-buildpacks_bundle-install/gems

I expect that it either:

  • Errors because the Gemfile.lock is out of sync; or
  • Rebuilds the layer

Cached gems layer reused even when ruby minor version changes

What happened?

We built a Ruby app with version 2.7.2 of mri, then rebuilt it, changing the version to 2.6.6. The app failed to run after rebuild because it was not able to find the required gems.

Reproduction Steps

  1. Clone this sample app
  2. Generate a Gemfile.lock by running bundle install locally.
  3. Add a buildpack.yml that specifies an MRI version:
---

mri:
  version: 2.7.2
  1. Build the app:
pack build changing-version --builder paketobuildpacks/builder:0.1.20-base --buildpack gcr.io/paketo-buildpacks/ruby:0.1.5 --clear-cache
  1. Run the app
docker run -d --env PORT=8080 --publish 8080:8080 changing-version
  1. And see the expected output when accessing it:
curl 0.0.0.0:8080
<!DOCTYPE html>
  <html>
    <head>
      <title>Powered By Paketo Buildpacks</title>
    </head>
    <body>
      <img style="display: block; margin-left: auto; margin-right: auto; width: 50%;" src="https://paketo.io/images/paketo-logo-full-color.png"></img>
    </body>
  </html>
  1. Then, change the buildpack.yml to specify a different MRI version:
---

mri:
  version: 2.6.6
  1. Rebuild the app without clearing the cache:
 pack build changing-version --builder paketobuildpacks/builder:0.1.20-base --buildpack gcr.io/paketo-buildpacks/ruby:0.1.5
  1. Note that build output includes:
[builder] Paketo Bundle Install Buildpack 0.1.0
[builder]   Reusing cached layer /layers/paketo-buildpacks_bundle-install/gems
[builder]
  1. Re-run the app (in interactive mode); note the error output:
docker run -it --env PORT=8080 --publish 8080:8080 changing-version
bundler: command not found: puma
Install missing gem executables with `bundle install`
  1. Re-run the app and jump into the container; note that the gems are in a ruby/2.7.0 directory
docker run -it --env PORT=8080 --publish 8080:8080  --entrypoint=launcher changing-version  /bin/bash
cnb@80bec5a816a0:/workspace$ ll /layers/paketo-buildpacks_bundle-install/gems/ruby/
total 12
drwxr-xr-x 3 cnb cnb 4096 Jan  1  1980 ./
drwxr-xr-x 4 cnb cnb 4096 Jan  1  1980 ../
drwxr-xr-x 9 cnb cnb 4096 Jan  1  1980 2.7.0/

The buildpack should rebuild the gem layer when the minor version of ruby changes, because the gems will need to be placed in a different subdirectory.

Checklist

Please confirm the following:

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.

Output from `bundle install` command

Currently the building stage output does not include the output from running bundle install:

Paketo Bundle Install Buildpack 0.0.60
  Executing build process
    Running 'bundle config path /layers/paketo-buildpacks_bundle-install/gems'
    Running 'bundle config cache_path --parseable'
    Running 'bundle install'
      Completed in 20.239s

Could we get this output included please to show progress?

bundle-install fails to install the mysql2 gem

What happened?

Please provide some details about the task you are trying to accomplish and
what went wrong.

  • What were you attempting to do?

Build a ruby application that has the mysql2 gem specified in it's Gemfile.

This worked after building a new stack build image on top of the CNB Full Stack build image and running apt-get install libmysqlclient-dev.

  • What did you expect to happen?

The image to successfully build.

It looks like there's a variant of the libmariadb-dev library but it doesn't seem to meet the requirements for the mysql2 gem: https://github.com/paketo-buildpacks/stacks/blob/caf3e44bd54c3a8cc4da0dafe65d3d875142a908/packages/full/build#L89-L90

  • What was the actual behavior? Please provide log output, if possible.
Installing mysql2 0.5.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/layers/paketo-buildpacks_bundle-install/gems/ruby/2.5.0/gems/mysql2-0.5.3/ext/mysql2
/layers/paketo-buildpacks_mri/mri/bin/ruby -r ./siteconf20201203-76-wo6d1g.rb
extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
checking for -lmysqlclient... no
-----
mysql client is missing. You may need to 'sudo apt-get install libmariadb-dev',
'sudo apt-get install libmysqlclient-dev' or 'sudo yum install mysql-devel', and
try again.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Build Configuration

Please provide some details about your build configuration.

  • What platform (pack, kpack, tekton buildpacks plugin, etc.) are you using? Please include a version.
  • Latest CNB Full Stack
  • pack cli version 0.14.1
  • What buildpacks are you using? Please include versions.
===> DETECTING
======== Results ========
pass: paketo-buildpacks/[email protected]
pass: paketo-buildpacks/[email protected]
pass: paketo-buildpacks/[email protected]
pass: paketo-buildpacks/[email protected]
pass: paketo-buildpacks/[email protected]
  • What builder are you using? If custom, can you provide the output from pack inspect-builder <builder>?

A custom builder with the paketo-buildpacks ruby buildpack specified.

  • Can you provide a sample app or relevant configuration (buildpack.yml,
    nginx.conf, etc.)?

We don't need a buildpack.yml for this app, and the Gemfile contains:

...
  gem "mysql2"
...

Checklist

Please confirm the following:

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.

Pack always assume production image is being built

What happened?

Trying to build an container for ci test runs, and the development/test gems are missing

  • What were you attempting to do?
    I'm trying to build a image to use in multiple different CI runs, thus the development:test gems are need in the launch layer.

  • What did you expect to happen?
    A way to the launch layer to be configured to allow development and test gems to be included

  • What was the actual behavior? Please provide log output, if possible.

Build Configuration

  • What platform (pack, kpack, tekton buildpacks plugin, etc.) are you
    using? Please include a version.

pack: 0.21.1

  • What buildpacks are you using? Please include versions.

paketo-buildpacks/ca-certificates 2.4.0
paketo-buildpacks/mri 0.2.5
paketo-buildpacks/bundler 0.1.9
paketo-buildpacks/bundle-install 0.2.4
paketo-buildpacks/node-engine 0.7.1
paketo-buildpacks/yarn 0.4.0
paketo-buildpacks/yarn-install 0.4.0
paketo-buildpacks/rails-assets 0.2.4
paketo-buildpacks/puma 0.0.61
paketo-buildpacks/procfile 4.3.0

  • What builder are you using? If custom, can you provide the output from pack inspect-builder <builder>?

paketobuildpacks/builder:full

  • Can you provide a sample app or relevant configuration (buildpack.yml,
    nginx.conf, etc.)?

Checklist

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.

Ruby gems should get reused rather than rebuilt

When I am pack building a ruby app that has a Gemfile
I Want my gems to be reused when possible
So That my app is built faster

Given
I am building a ruby app that has a Gemfile
When
The gems can be reused and pulled rather than re-built
Then
The gems are reused and I am informed that the gems were reused

Bundler configuration should be moved into a layer

Summary

The current implementation makes a few modifications to the Bundler configuration as it executes:

  1. Setting the path to the gems layer
  2. Excluding development and test group gems when installing
  3. Ensuring bundle clean is executed after the installation completes

These configuration settings modify any of the settings that may already be set in the working directory in .bundle/config. They also won't be persisted beyond this given build of the application. So, we may lose some useful configuration settings if the layer is reused and the configuration is not repopulated on a subsequent build.

Proposal

If the .bundle/config file exists, we should copy it into the gems layer. Then we should set the BUNDLE_APP_CONFIG environment variable to point to the new layer path. The bundle config docs outline that it will look at $BUNDLE_APP_CONFIG/config for configuration settings. Finally, when setting the above enumerated configuration options in the build process, we should use the --local flag to ensure it records those values to the config file in the gems layer. At this point, it is reasonable to remove the BUNDLE_PATH and BUNDLE_WITHOUT environment variables and to only set the BUNDLE_APP_CONFIG environment variable as it should supersede these environment variable values.

Handle `build` and `launch` dependencies separately

Summary

The buildpack currently only installs those gems that do not belong to the development or test groups in the Gemfile. Unfortunately, some buildpacks may need access to development or test gems during their build phase. We should enable those buildpacks to have access to those gems if they request that gems be made available during the build phase.

Proposal

  1. If the build plan entry includes a launch entry in the metadata, then the buildpack should install the "production" gems (excluding development and test) into a layer that is made available at launch. This is the buildpack's current behavior.

  2. If the build plan entry includes a build entry in the metadata, then the buildpack should install all gems (including development and test) into a layer that is made available at build. This is net-new behavior.

  3. If the build plan entry contains both a launch and build entry in the metadata, then the buildpack should do both of the above behaviors, resulting in 2 layers, but with different lifecycle phase access and purposes.

Bundle-install does not respect `build` and `launch` flags in Buildpack Plan

Context:
Currently bundle-install hardcodes that it is a layer that is required during launch here:

gemsLayer, err := context.Layers.Get(LayerNameGems, packit.LaunchLayer)

This hardcoding ignores requirements that are made be other buildpacks in their Build Plans. This is an anti-pattern for the Paketo Buildpacks and eliminates the ability for other integrating buildpacks to require gems during the build phase.

Proposal:
Bundle-install should have a strategy similar to other Paketo Buildpacks where is merges Buildpack Plan entry metadata to find the build and launch requirements.

Is the vendor/cache directory with gems being used on subsequent image builds?

Hey there ๐Ÿ‘‹

I am testing the performance of building an image with buildpacks vs using a dockerfile with buildkit enabled.

For a given ruby app:

  1. I build the image
  2. Bump a gem (puma 4.1 -> 4.3) and run bundle install
  3. I build the image again

I expect the second build to be fast since all of the other gems are available in the vendor/cache directory.

With docker buildkit, this step takes ~2 seconds.

 => [stage-0 10/16] RUN --mount=type=cache,uid=1000,gid=1000,target=/app/.cache/gems     --network=none     bundle install --local &&     cp -ar .cache/gems   2.3s

With the buildpack, it took a few minutes:

2020/10/13 16:25:29.971038 Paketo Bundle Install Buildpack 0.0.59
2020/10/13 16:25:29.971201   Executing build process
    Running 'bundle config path /layers/paketo-buildpacks_bundle-install/gems'
2020/10/13 16:25:30.100074     Running 'bundle config cache_path --parseable'
2020/10/13 16:25:30.218272     Running 'bundle install --local'
2020/10/13 16:28:16.406565       Completed in 2m46.624s

Since the app has a vendor/cache directory with the gems already available, I expected a rebuild after a single gem change to be faster.

Only reuse launch process cache layer when test/development gem changes

What happened?

  • What were you attempting to do?

Following the completion of #182, I tested out the code which installs development and test gems during the build phase. I performed a rebuild of an app with test gems, and I changed a test gem (same experience fordevelopment gem change) it caused both the build and launch install process to re-run.

When I changed a production gem on a rebuild, it also caused both the build and launch install process to re-run.

  • What did you expect to happen?

I would have only expected the relevant install process to rerun depending on the type of gem. For example, when changing a test gem I would've expected only the build process the rerun, but the launch process cache layer to be reused so that my rebuild is more performant.

Build Configuration

  • What platform (pack, kpack, tekton buildpacks plugin, etc.) are you
    using? Please include a version.

pack 0.18.0

  • What buildpacks are you using? Please include versions.

bundle-install v0.2.0

  • Can you provide a sample app or relevant configuration (buildpack.yml,
    nginx.conf, etc.)?

https://github.com/paketo-buildpacks/bundle-install/tree/main/integration/testdata/simple_app

Checklist

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.

Run without development and test groups.

What happened?

  • What were you attempting to do?

Run an application image created with this buildpack. The spring gem is only available in the development group of the gemfile.

  group :development do
    gem "spring"
  end
  • What did you expect to happen?

For it to start without spring without needing to explicitly set DISABLE_SPRING=1 in the environment.

  • What was the actual behavior? Please provide log output, if possible.
Running via Spring preloader in process 20
WARNING: Spring is running in production. To fix this make sure the spring gem is only present in `development` and `test` groups in your Gemfile and make sure you always use `bundle install --without development test` in production

Build Configuration

  • What platform (pack, kpack, tekton buildpacks plugin, etc.) are you
    using? Please include a version.

Latest pack

  • What buildpacks are you using? Please include versions.

Latest ruby buildpack

  • What builder are you using? If custom, can you provide the output from pack inspect-builder <builder>?

Custom builder

  • Can you provide a sample app or relevant configuration (buildpack.yml,
    nginx.conf, etc.)?

Checklist

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.

Offline bundle install support

Context
If my app is vendored and I am running in an offline environment I should still be able to run bundle install in offline mode.

Proposal
Enable an offline bundle install workflow in this buildpack and write integration tests for it.

Acceptance Criteria
GIVEN I have a vendored ruby app in an offline environment
THEN I can run a pack build
AND get a functioning app the result

Layer Reuse between builds

Context
If there is no change in the gems that are needed to run an app then the buildpack should reuse the gem layer from a previous build.

Proposal
Enable a gem layer reuse between builds and provide an integration test.

Acceptance Criteria
GIVEN I have a ruby app
AND my gem environment does not change between builds
THEN I can run a pack build on that same app
AND it will reuse the gem layer from my pervious build

Failed to satisfy "bundler" dependency version constraint "2.1.4": no compatible versions. Supported versions are: [1.17.3, 2.2.3, 2.2.4]

What happened?

With the recent builder image update, the build of application https://github.com/cloudfoundry/cf-acceptance-tests/tree/develop/assets/dora stopped working. It fails with:

Paketo Bundler Buildpack 0.1.0
   Resolving Bundler version
     Candidate version sources (in priority order):
       Gemfile.lock -> "2.1.4"
       <unknown>    -> "*"
       <unknown>    -> "*"
failed to satisfy "bundler" dependency version constraint "2.1.4": no compatible versions. Supported versions are: [1.17.3, 2.2.3, 2.2.4]
  • What were you attempting to do?

See above

  • What did you expect to happen?

The build should continue to succeed

  • What was the actual behavior? Please provide log output, if possible.

It failed. I started a discussion in Slack about this behavior. The buildpack tries to exactly match the BUNDLED WITH version in the Gemfile.lock with the available bundler versions. This is unexpected to colleague who is more Ruby expect than me. The lockfile certainly defines the exact version of the gems that are to be installed, but not which bundler version must be used. Outcome of the slack discussion currently is that the check should be relaxed to filter one the major version only -> 2.1.4 in the lockfile should pick the newest 2.* bundler included in the buildpack which would be 2.2.4 in my case.

Build Configuration

Please provide some details about your build configuration.

  • What platform (pack, kpack, tekton buildpacks plugin, etc.) are you using? Please include a version.

Shipwright Build which is based on Tekton 1.18.1.

  • What buildpacks are you using? Please include versions.

I am using the 0.1.66-full builder image and the creator command. The versions can be seen here: https://github.com/paketo-buildpacks/full-builder/releases/tag/v0.1.66

  • What builder are you using? If custom, can you provide the output from pack inspect-builder <builder>?

  • Can you provide a sample app or relevant configuration (buildpack.yml,
    nginx.conf, etc.)?

https://github.com/cloudfoundry/cf-acceptance-tests/tree/develop/assets/dora

Checklist

Please confirm the following:

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.

Buildpack creates bloated application images

What happened?

When the Ruby version is modified in an app's Gemfile, the cached versions of ruby from previous builds are preserved in the final gems layer.

Please provide some details about the task you are trying to accomplish and
what went wrong.

  • What were you attempting to do?

We modified

first to ruby '~> 2.6.6' and pack built the application. Next, we changed the line once again to ruby '~> 2.7.2' and rebuilt the application.

  • What did you expect to happen?

It was expected that layers/paketo-buildpacks_bundle-install/gems/ruby/ would only contain a 2.7.0 directory on the second build.

  • What was the actual behavior? Please provide log output, if possible.

layers/paketo-buildpacks_bundle-install/gems/ruby/ contained both 2.6.0 and 2.7.0 directories.

First build:

===> DETECTING
[detector] 4 of 5 buildpacks participating
[detector] paketo-buildpacks/mri            0.0.164
[detector] paketo-buildpacks/bundler        0.0.153
[detector] paketo-buildpacks/bundle-install 0.1.1
[detector] paketo-buildpacks/rackup         0.0.48
===> ANALYZING
[analyzer] Previous image with name "index.docker.io/library/testv3cache:latest" not found
===> RESTORING
===> BUILDING
[builder] Paketo MRI Buildpack 0.0.164
[builder]   Resolving MRI version
[builder]     Candidate version sources (in priority order):
[builder]       <unknown> -> "~> 2.6.6"
[builder]       <unknown> -> "*"
[builder]
[builder]     Selected MRI version (using <unknown>): 2.6.6
[builder]
[builder]   Executing build process
[builder]     Installing MRI 2.6.6
[builder]       Completed in 1.487s
[builder]
[builder]   Configuring environment
[builder]     GEM_PATH -> "/home/cnb/.gem/ruby/2.6.0:/layers/paketo-buildpacks_mri/mri/lib/ruby/gems/2.6.0"
[builder]
[builder] Paketo Bundler Buildpack 0.0.153
[builder]   Resolving Bundler version
[builder]     Candidate version sources (in priority order):
[builder]       <unknown> -> "*"
[builder]       <unknown> -> "*"
[builder]
[builder]     Selected Bundler version (using <unknown>): 2.1.4
[builder]
[builder]   Executing build process
[builder]     Installing Bundler 2.1.4
[builder]       Completed in 198ms
[builder]
[builder]   Configuring environment
[builder]     GEM_PATH -> "$GEM_PATH:/layers/paketo-buildpacks_bundler/bundler"
[builder]
[builder] Paketo Bundle Install Buildpack 0.1.1
[builder]   Executing build process
[builder]     Running 'bundle config path /layers/paketo-buildpacks_bundle-install/gems'
[builder]     Running 'bundle config clean true'
[builder]     Running 'bundle config cache_path --parseable'
[builder]     Running 'bundle install'
[builder]       Completed in 2.617s
[builder]
[builder]   Configuring environment
[builder]     BUNDLE_PATH -> "/layers/paketo-buildpacks_bundle-install/gems"
[builder]
[builder] Paketo Rackup Buildpack 0.0.48
[builder]   Writing start command
[builder]     bundle exec rackup -p "${PORT:-9292}"
===> EXPORTING
[exporter] Adding layer 'paketo-buildpacks/mri:mri'
[exporter] Adding layer 'paketo-buildpacks/bundler:bundler'
[exporter] Adding layer 'paketo-buildpacks/bundle-install:gems'
[exporter] Adding 1/1 app layer(s)
[exporter] Adding layer 'launcher'
[exporter] Adding layer 'config'
[exporter] Adding layer 'process-types'
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] Setting default process type 'web'
[exporter] *** Images (d6f54b1dced3):
[exporter]       index.docker.io/library/testv3cache:latest
[exporter] Adding cache layer 'paketo-buildpacks/mri:mri'
[exporter] Adding cache layer 'paketo-buildpacks/bundler:bundler'
[exporter] Adding cache layer 'paketo-buildpacks/bundle-install:gems'
Successfully built image testv3cache

Second build:

===> DETECTING
[detector] 4 of 5 buildpacks participating
[detector] paketo-buildpacks/mri            0.0.164
[detector] paketo-buildpacks/bundler        0.0.153
[detector] paketo-buildpacks/bundle-install 0.1.1
[detector] paketo-buildpacks/rackup         0.0.48
===> ANALYZING
[analyzer] Restoring metadata for "paketo-buildpacks/mri:mri" from app image
[analyzer] Restoring metadata for "paketo-buildpacks/bundler:bundler" from app image
[analyzer] Restoring metadata for "paketo-buildpacks/bundle-install:gems" from app image
===> RESTORING
[restorer] Restoring data for "paketo-buildpacks/mri:mri" from cache
[restorer] Restoring data for "paketo-buildpacks/bundler:bundler" from cache
[restorer] Restoring data for "paketo-buildpacks/bundle-install:gems" from cache
===> BUILDING
[builder] Paketo MRI Buildpack 0.0.164
[builder]   Resolving MRI version
[builder]     Candidate version sources (in priority order):
[builder]       <unknown> -> "~> 2.7.2"
[builder]       <unknown> -> "*"
[builder]
[builder]     Selected MRI version (using <unknown>): 2.7.2
[builder]
[builder]   Executing build process
[builder]     Installing MRI 2.7.2
[builder]       Completed in 1.118s
[builder]
[builder]   Configuring environment
[builder]     GEM_PATH -> "/home/cnb/.gem/ruby/2.7.0:/layers/paketo-buildpacks_mri/mri/lib/ruby/gems/2.7.0"
[builder]
[builder] Paketo Bundler Buildpack 0.0.153
[builder]   Resolving Bundler version
[builder]     Candidate version sources (in priority order):
[builder]       <unknown> -> "*"
[builder]       <unknown> -> "*"
[builder]
[builder]     Selected Bundler version (using <unknown>): 2.1.4
[builder]
[builder]   Reusing cached layer /layers/paketo-buildpacks_bundler/bundler
[builder]
[builder] Paketo Bundle Install Buildpack 0.1.1
[builder]   Executing build process
[builder]     Running 'bundle config path /layers/paketo-buildpacks_bundle-install/gems'
[builder]     Running 'bundle config clean true'
[builder]     Running 'bundle config cache_path --parseable'
[builder]     Running 'bundle install'
[builder]       Completed in 2.541s
[builder]
[builder]   Configuring environment
[builder]     BUNDLE_PATH -> "/layers/paketo-buildpacks_bundle-install/gems"
[builder]
[builder] Paketo Rackup Buildpack 0.0.48
[builder]   Writing start command
[builder]     bundle exec rackup -p "${PORT:-9292}"
===> EXPORTING
[exporter] Adding layer 'paketo-buildpacks/mri:mri'
[exporter] Reusing layer 'paketo-buildpacks/bundler:bundler'
[exporter] Adding layer 'paketo-buildpacks/bundle-install:gems'
[exporter] Adding 1/1 app layer(s)
[exporter] Reusing layer 'launcher'
[exporter] Adding layer 'config'
[exporter] Reusing layer 'process-types'
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] Setting default process type 'web'
[exporter] *** Images (e1efdee9ddd1):
[exporter]       index.docker.io/library/testv3cache:latest
[exporter] Adding cache layer 'paketo-buildpacks/mri:mri'
[exporter] Reusing cache layer 'paketo-buildpacks/bundler:bundler'
[exporter] Adding cache layer 'paketo-buildpacks/bundle-install:gems'
Successfully built image testv3cache

Resulting gems layer directory:

cnb@8b4921868f90:/$ ll layers/paketo-buildpacks_bundle-install/gems/ruby/
total 16
drwxr-xr-x 4 cnb cnb 4096 Jan  1  1980 ./
drwxr-xr-x 4 cnb cnb 4096 Jan  1  1980 ../
drwxr-xr-x 9 cnb cnb 4096 Jan  1  1980 2.6.0/
drwxr-xr-x 9 cnb cnb 4096 Jan  1  1980 2.7.0/

Build Configuration

Please provide some details about your build configuration.

  • What platform (pack, kpack, tekton buildpacks plugin, etc.) are you using? Please include a version.
    pack v0.13.1+git-4134cc6.build-1135

  • What buildpacks are you using? Please include versions.
    pack inspect-builder output:

paketo-buildpacks/[email protected]
 โ”‚     โ”œ Group #5:
 โ”‚     โ”‚  โ”œ paketo-buildpacks/[email protected]
 โ”‚     โ”‚  โ”œ paketo-buildpacks/[email protected]
 โ”‚     โ”‚  โ”œ paketo-buildpacks/[email protected]
 โ”‚     โ”‚  โ”œ paketo-buildpacks/[email protected]
 โ”‚     โ”‚  โ”” paketo-buildpacks/[email protected]          (optional)
  • What builder are you using? If custom, can you provide the output from pack inspect-builder <builder>?
    index.docker.io/paketobuildpacks/builder:full-cf

  • Can you provide a sample app or relevant configuration (buildpack.yml,
    nginx.conf, etc.)?
    Sample app

Checklist

Please confirm the following:

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.

NOTE: This may be resolved by addressing #112

Bundle install reuses layer even when bundle-respected env vars should change app image setup

What happened?

Please provide some details about the task you are trying to accomplish and
what went wrong.
We were trying to use some build-time configuration that the bundle tool natively respects to change the contents of the built app image. In particular, we wanted to take advantage of the BUNDLE_WITHOUT environment variable to exclude certain gems from the built app image. Rather than rebuilding the gems layer, the buildpack reused the cached version of the layer. The resulting app image included gems we didn't want in our image.

Reproduction steps

  1. Clone this sample app
  2. Change the Gemfile to contain:
source 'https://rubygems.org'

ruby '~> 2.0'

group :test do
  gem 'rspec'
end

gem 'puma'
gem 'sinatra'
  1. Run bundle locally to generate a Gemfile.lock.
  2. Build the app with all of its gems:
pack build exclude-gems  --builder paketobuildpacks/builder:0.1.20-base --buildpack gcr.io/paketo-buildpacks/ruby:0.1.5 --clear-cache
  1. Hop into the built app and see that the rspec gem is present:
docker run -it --entrypoint=launcher exclude-gems /bin/bash
cnb@fa0d8cb9967f:/workspace$ ls /layers/paketo-buildpacks_bundle-install/gems/ruby/2.7.0/gems/
diff-lcs-1.4.4    nio4r-2.5.4  rack-2.2.3             rspec-3.10.0       rspec-expectations-3.10.0  rspec-support-3.10.0  sinatra-2.1.0
mustermann-1.1.1  puma-5.0.4   rack-protection-2.1.0  rspec-core-3.10.0  rspec-mocks-3.10.0         ruby2_keywords-0.0.2  tilt-2.0.10
  1. Rebuild the app with the BUNDLE_WITHOUT env var to exclude the test group:
pack build exclude-gems  --builder paketobuildpacks/builder:0.1.20-base --buildpack gcr.io/paketo-buildpacks/ruby:0.1.5 --env BUNDLE_WITHOUT=test

The output should contain:

[builder] Paketo Bundle Install Buildpack 0.1.0
[builder]   Reusing cached layer /layers/paketo-buildpacks_bundle-install/gems
[builder]
  1. Hop into the app container again and see that rspec is still present in the app container
docker run -it --entrypoint=launcher exclude-gems /bin/bash
cnb@546bd3d68aea:/workspace$ ls /layers/paketo-buildpacks_bundle-install/gems/ruby/2.7.0/gems/
diff-lcs-1.4.4    nio4r-2.5.4  rack-2.2.3             rspec-3.10.0       rspec-expectations-3.10.0  rspec-support-3.10.0  sinatra-2.1.0
mustermann-1.1.1  puma-5.0.4   rack-protection-2.1.0  rspec-core-3.10.0  rspec-mocks-3.10.0         ruby2_keywords-0.0.2  tilt-2.0.10

The buildpack should rebuild the gems layer in a way that respects this native configuration.
Notably, running

pack build exclude-gems  --builder paketobuildpacks/builder:0.1.20-base --buildpack gcr.io/paketo-buildpacks/ruby:0.1.5 --env BUNDLE_WITHOUT=test --clear-cache

produces the desired result, where rspec gems are not present.

Checklist

Please confirm the following:

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.

Implement RFC0038: SBOM

To implement Paketo RFC0038, this buildpack will need to move from storing SBOM information in layer metadata to storing it in files that the CNB lifecycle can manipulate during the build. The RFC outlines what these files are and what they should contain.

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.