Skip to content

pack builder create --flatten doesn't flatten any layers #2050

@edmorley

Description

@edmorley

Summary

The new --flatten option to pack builder create added in Pack CLI 0.33.0 doesn't appear to work, since the output builder image has the same number of layers as when --flatten hadn't been used at all.


Reproduction

Steps
  1. git clone https://github.com/heroku/cnb-builder-images testcase && cd $_
  2. git checkout 94d5427d577c3a2615c2909cb6392841b0e626c8
  3. pack builder create --verbose --config builder-22/builder.toml builder-original
  4. pack builder create --verbose --config builder-22/builder.toml --flatten 'heroku/gradle@4.1.0,heroku/java@4.1.0,heroku/jvm@4.1.0,heroku/maven@4.1.0,heroku/sbt@4.1.0,heroku/scala@4.1.0' builder-flattened
  5. docker history -q builder-original | wc -l
  6. docker history -q builder-flattened | wc -l
Current behavior

The builder image created using --flatten has the same number of layers as the one created without using --flatten.

$ docker history -q builder-original | wc -l
32
$ docker history -q builder-flattened | wc -l
32
Expected behavior

For the builder-flattened builder to have fewer layers, due to flattening.

See here for the builder manifest being used:
https://github.com/heroku/cnb-builder-images/blob/94d5427d577c3a2615c2909cb6392841b0e626c8/builder-22/builder.toml


Environment

pack info
$ pack report
Pack:
  Version:  0.33.0+git-e3f8bc2.build-5475
  OS/Arch:  darwin/arm64

Default Lifecycle Version:  0.18.4

Supported Platform APIs:  0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.10, 0.11, 0.12

Config:
  default-builder-image = "[REDACTED]"
  experimental = true

  [[trusted-builders]]
    name = "[REDACTED]"

  [[trusted-builders]]
    name = "[REDACTED]"
docker info
$ docker info
Client:
 Version:    25.0.2
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1-desktop.4
    Path:     /Users/emorley/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.3-desktop.1
    Path:     /Users/emorley/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container. (Docker Inc.)
    Version:  0.0.22
    Path:     /Users/emorley/.docker/cli-plugins/docker-debug
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/emorley/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.21
    Path:     /Users/emorley/.docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     /Users/emorley/.docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.0.0
    Path:     /Users/emorley/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/emorley/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.3.0
    Path:     /Users/emorley/.docker/cli-plugins/docker-scout
WARNING: Plugin "/Users/emorley/.docker/cli-plugins/docker-scan" is not valid: failed to fetch metadata: fork/exec /Users/emorley/.docker/cli-plugins/docker-scan: no such file or directory

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 12
 Server Version: 25.0.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.6.12-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 10
 Total Memory: 15.6GiB
 Name: docker-desktop
 ID: <SNIP>
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/readyIssue ready to be worked on.type/bugIssue that reports an unexpected behaviour.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions