buildpacks / pack

CLI for building apps using Cloud Native Buildpacks
https://buildpacks.io
Apache License 2.0
2.56k stars 286 forks source link

pack is throwing invalid buildpack string error when version is provided for a buildpack #869

Closed Infra-Red closed 3 years ago

Infra-Red commented 4 years ago

Summary

When I specify a buildpack version with the --buildpack flag for the pack build command, pack returns the following error saying that invalid buildpack string was provided.

❯ pack build go-sample -b gcr.io/paketo-buildpacks/go@0.1.3 -B paketobuildpacks/builder:tiny
ERROR: failed to build: invalid buildpack string gcr.io/paketo-buildpacks/go@0.1.3

It works if I provide a buildpack version in the buildpack:version format, while pack build --help shows that buildpack@version should be used.

❯ pack build --help
-b, --buildpack strings        Buildpack reference in the form of '<buildpack>@<version>',
                                   path to a buildpack directory (not supported on Windows),
                                   path/URL to a buildpack .tar or .tgz file, or
                                   the name of a packaged buildpack image
                                 Repeat for each buildpack in order,
                                   or supply once by comma-separated list

Which format should be used to specify a buildpack version when using pack build?


Reproduction

Steps
  1. Clone the Paketo sample apps repo.
    git clone https://github.com/paketo-buildpacks/samples
    cd samples
  2. Build the app and explicitly set a buildpack version:
    cd go/mod
    pack build go-sample -b gcr.io/paketo-buildpacks/go@0.1.3 -B paketobuildpacks/builder:tiny
Current behavior

pack returns an error and tells me that invalid buildpack string was provided.

Expected behavior

pack should build the app using provided buildpack version.


Environment

pack info
❯ pack report
Pack:
  Version:  0.14.1+git-b630309.build-1353
  OS/Arch:  darwin/amd64

Default Lifecycle Version:  0.9.1

Supported Platform APIs:  0.3, 0.4

Config:
  default-builder-image = "[REDACTED]"
docker info
❯ docker info
Client:
 Debug Mode: false

Server:
 Containers: 16
  Running: 0
  Paused: 0
  Stopped: 16
 Images: 147
 Server Version: 19.03.13
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.76-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 7.779GiB
 Name: docker-desktop
 ID: LMAM:KZWE:YDUP:3CXY:KWEU:JQ74:6VVB:VMBB:RA4H:HQEK:YG7B:ZNF5
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 40
  Goroutines: 47
  System Time: 2020-10-02T20:20:23.728284Z
  EventsListeners: 3
 HTTP Proxy: gateway.docker.internal:3128
 HTTPS Proxy: gateway.docker.internal:3129
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine
jromero commented 4 years ago

There are 4 types of acceptable inputs to the --buildpack flag.

  1. a buildpack by id and version. eg. my-buildpack@1.2.3
  2. path to a directory. eg. ./my-buildpack/
  3. path/url to tgz/zip. eg. https://example.com/my-buildpack.tgz
  4. an image name. eg. gcr.io/my-image:latest

The first option, buildpack ID + version, is acceptable for buildpacks already in the builder (and in the near future via buildpack registry).

For images, as you've provide, the format is using the standard OCI image format. <hostname:>/<repo>[:<tag>]

Hope this helps demystify how this works. If you have any suggesting for future clarification that can be added to the help screen, we'd love to hear it.

Infra-Red commented 4 years ago

I would suggest to extend the help message for the buildpack reference and for the image name with additional examples as you showed in the post above. I can submit a PR if you agree with this.

dfreilich commented 3 years ago

That would be great, @Infra-Red ! More help on documentation is always appreciated.

Infra-Red commented 3 years ago

@dfreilich @jromero Please review when you can https://github.com/buildpacks/pack/pull/894. Thanks!