- TBS 1.0.2 is deployed
- Note: all steps leading up to the first step that uses the
kp
command can be done without TBS or kpack installed on a kubernetes cluster
- Note: all steps leading up to the first step that uses the
kp clusterstack list
shows all stacks as READY
- Export git repo dir to an env var to make future commands easier
export ROOT_DIR=$PWD
- Install
pack
CLI (https://github.com/buildpacks/pack) git clone https://github.com/cloudfoundry-samples/spring-music
- Set the default builder to the same one TBS uses
pack set-default-builder <CONTAINER_REGISTRY_FQDN>/<TBS_PROJECT>/build-service/default
- If you dont have TBS installed, you can just use the Paketo builder be running
pack set-default-builder paketobuildpacks/builder:full
- If you dont have TBS installed, you can just use the Paketo builder be running
- Make sure the image builds with the default builder
pack build spring-music -p $ROOT_DIR/spring-music --trust-builder
- When you run
pack build spring-music -p $ROOT_DIR/spring-music -b $ROOT_DIR/sample-buildpack --trust-builder
the following will happen:sample-buildpack/bin/detect
will be run from the root of the git repo specified (e.g. thespring-music
directory) and determine whether or not to run whatever is insample-buildpack/bin/build
. In this case it will run becausemanifest.yml
, inside thespring-music
directory, contains the string "spring-music"sample-buildpack/bin/detect
will persist an environment variable calledDEPENDENCIES_DIR
that points to the directory (layer) where it will copy a file calledhelloworld
- After running the above command, enter the container by running
docker run -it --entrypoint launcher spring-music bash
- Navigate to the layer directory that we added using the buildpack
cd $DEPENDENCIES_DIR
and inspect the file we copied incat helloworld
- Package the buildpack using
pack package-buildpack helloworld-buildpack --config ./package.toml
and see that it now exists indocker images
- Use the packaged buildpack by running
pack build spring-music -p $ROOT_DIR/spring-music -b helloworld-buildpack --trust-builder
- Push the buildpack to your container repo
docker tag helloworld-buildpack <CONTAINER_REGISTRY_FQDN>/<SOME_PROJECT>/<TBS_PROJECT>/helloworld-buildpack
anddocker push <CONTAINER_REGISTRY_FQDN>/<SOME_PROJECT>/<TBS_PROJECT>/helloworld-buildpack
- Add the custom buildpack to the default clusterstore
kp clusterstore add default -b <CONTAINER_REGISTRY_FQDN>/<SOME_PROJECT>/<TBS_PROJECT>/helloworld-buildpack
and notice that it uploads it as<CONTAINER_REGISTRY_FQDN>/<SOME_PROJECT>/build-service/<BUILDPACK_ID>
- Edit the default clusterbuilder and add this buildpack to the order
kubectl edit clusterbuilder default
- Under
spec.order
add the following lines- group: - id: sample-buildpack
- Ensure the buildpack is shown in the output of
kp clusterbuilder status default
- Build the image using TBS
kp image create spring-music --tag <CONTAINER_REGISTRY_FQDN>/<SOME_PROJECT>/spring-music --git https://github.com/cloudfoundry-samples/spring-music --git-revision master
- Pull the TBS-built container image down and verify the helloworld file is there:
docker pull <CONTAINER_REGISTRY_FQDN>/<SOME_PROJECT>/spring-music
docker run -it --entrypoint launcher spring-music bash
cd $DEPENDENCIES_DIR
cat helloworld