buildpacks / roadmap

Issue tracker
https://buildpacks.io
Apache License 2.0
0 stars 0 forks source link

Cache layers in an OCI image instead of a inter-build volume #39

Closed sclevine closed 5 years ago

sclevine commented 5 years ago

Lifecycle

cacher

lifecycle images should have two new binaries cacher and restorer

When A platform invokes cacher -layers=<layers-dir> -group=<group.toml> -image=<cache-image-tag> Then a image <cache-image-tag> should be written to the docker daemon where all layers in the layers dir with cache=true that corresponding to buildpacks listed in group.toml are added as layers Then the label io.buildpacks.lifecycle.metadata on the cache image should be populated with the cache layer shas and metadata

Given an image <cache-image-tag> already exists When A platform invokes cacher -layers=<layers-dir> -group=<group.toml> -image=<cache-image-tag> Then The cacher should reuse layers from the previous image when possible

restorer

When A platform invokes restorer -layers=<layers-dir> -group=<group.toml> -image=<cache-image-tag> Then All layers corresponding to buildpacks listed in group.toml will be written to the <layers-dir>

analyzer and exporter

Pack

When pack build fails or is interrupted before completing the lifecycle Then the cache is not corrupted

When pack build is called with the --clear-cache flag, the cache image is removed before the lifecycle begins

Note: this is a breaking lifecycle change and will require a new lifecycle version line

ekcasey commented 5 years ago

Steps to accept:

pack version: v0.1.0-build.20-darwin pack location: https://storage.cloud.google.com/cloud-native-buildpacks-pack-binaries/development/pack-0.1.0-build.20-darwin lifecycle version: 3.0.0-alpha.3-build.9 builder location: gcr.io/cncf-buildpacks-ci/packs/samples:3.0.0-alpha.3-build.9

Download pack and make it executable.

first build

run pack build with --builder gcr.io/cncf-buildpacks-ci/packs/samples:3.0.0-alpha.3-build.9 flag.

subsequent builds

Rerun pack build with --builder gcr.io/cncf-buildpacks-ci/packs/samples:3.0.0-alpha.3-build.9 and the same image name

interrupted builds

Rerun pack build with --builder gcr.io/cncf-buildpacks-ci/packs/samples:3.0.0-alpha.3-build.9 and cancel the build in the middle.

clear cache

Rerun pack build with --builder gcr.io/cncf-buildpacks-ci/packs/samples:3.0.0-alpha.3-build.9 and the --clear-cache flag.

UX questions

mgibson1121 commented 5 years ago
pack-cache-f958bbee0669180ca00b3d32062a48c2   latest                  e46d50050934        6 seconds ago        58.3MB
some_node_app_2                               latest                  f2012f73204a        10 seconds ago       324MB
<none>                                        <none>                  ab763ab4499b        About a minute ago   58.3MB
<none>                                        <none>                  6f5bf7e274ba        About a minute ago   324MB
<none>                                        <none>                  1cb3fb72d7b1        6 minutes ago        58.3MB
<none>                                        <none>                  7be014b7660e        6 minutes ago        324MB
gcr.io/cncf-buildpacks-ci/packs/samples       3.0.0-alpha.3-build.9   a038ae01bb8e        2 days ago           283MB
gcr.io/cncf-buildpacks-ci/packs/run           3.0.0-alpha.3-build.9   eaea915bd7fa        2 days ago           256MB

Tested w/ @sclevine. Seems like we're not cleaning up the old cache images. Each time I run pack build with the builder @ekcasey specified, the old cache image is left behind. Also, the image name appears to be very long in some places and short in others, which is confusing. Can probably use first seven characters. Rejecting the story because of the cache image issue, but would be nice to fix the sha length if the ticket is going back to in progress anyway.

sclevine commented 5 years ago

Looks good!