Skip to content

Layer cache is used when config has changed #1124

@ZephireNZ

Description

@ZephireNZ

Expected Behavior

When changing the buildpack environment variables, the buildpack layer cache should not be used so that a "fresh" build can take place.

Current Behavior

Changing environment variable (eg BP_WEB_SERVER from "nginx" to "" to disable auto-generation of nginx.conf) continues to re-use existing cached layer instead of building a fresh layer with auto-generation disabled.

Possible Solution

Include BP_WEB_SERVER (or maybe a hash of all env vars) in the layer metadata to act as a cache-buster.

Steps to Reproduce

  1. Build a sample app setting -e BP_WEB_SERVER=nginx, ensuring that cache is enabled
  2. Remove this environment variable and build again
  3. Notice that in the build log, layer is still reused
  4. Notice in /layers/paketo-buildpacks_nginx/nginx/env.launch/, env vars for APP_ROOT and PORT are still set when this should only happen when BP_WEB_SERVER=nginx

Motivations

This bug may catch out users who aren't aware that despite changing configuration, that config has not been used in their newly built image.

For us, we discovered it when switching to a hardcoded nginx.conf and were using {{env APP_ROOT}} until the layer cache got cleared causing builds to start failing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions