Skip to content

Instantly share code, notes, and snippets.

@miclip
Last active June 29, 2022 17:17
Show Gist options
  • Save miclip/41e44c0ee1beb3b82b976e8a74b263c5 to your computer and use it in GitHub Desktop.
Save miclip/41e44c0ee1beb3b82b976e8a74b263c5 to your computer and use it in GitHub Desktop.
Custom TBS Stack example

Create a custom stack and add to TBS

  1. Create a docker file for image:
# Set a common base
FROM alpine as base

# Set required CNB information
ENV CNB_USER_ID=1000
ENV CNB_GROUP_ID=1000
ENV CNB_STACK_ID="io.buildpacks.miclip.stacks.alpine"
LABEL io.buildpacks.stack.id="io.buildpacks.miclip.stacks.alpine"

# Create the user and group
RUN addgroup -S cnb --gid ${CNB_GROUP_ID} &&  adduser -S cnb -G cnb --uid ${CNB_USER_ID}


# ========== ADDED ===========
# Install common packages
RUN apk update && \
  apk add xz ca-certificates   

FROM base as run
USER ${CNB_USER_ID}:${CNB_GROUP_ID}
  1. Docker build and push stack image...
docker build . -t gcr.io/some-project/tbs-examples/alpine:1.0.0
docker push gcr.io/some-project/tbs-examples/alpine:1.0.0
  1. Add to TBS
kp clusterstack create alpine -b gcr.io/some-project/tbs-examples/alpine:1.0.0 \
  -r gcr.io/some-project/tbs-examples/alpine:1.0.0
  1. Verify stack
kp clusterstack list    

alpine     True     io.buildpacks.miclip.stacks.alpine
base       True     io.buildpacks.stacks.bionic
default    True     io.buildpacks.stacks.bionic
full       True     io.buildpacks.stacks.bionic
tiny       True     io.paketo.stacks.tiny

More information: https://buildpacks.io/docs/operator-guide/create-a-stack/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment