Last active
December 18, 2023 05:55
-
-
Save vfarcic/f744313878391196ae9aea5b9dc17071 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://gist.github.com/f744313878391196ae9aea5b9dc17071 | |
########################################################################## | |
# Container (Docker) Images Without Dockerfile With Buildpacks and kpack # | |
# https://youtu.be/fbSoKu8NGSU # | |
########################################################################## | |
# Additional Info: | |
# - Cloud Native Buildpacks: https://buildpacks.io | |
# - Paketo Buildpacks: https://paketo.io | |
# - kpack: https://github.com/pivotal/kpack | |
######### | |
# Setup # | |
######### | |
# Create a Kubernetes cluster | |
# Make sure that Docker is running | |
# Install `pack` CLI from https://buildpacks.io/docs/tools/pack | |
# Install `kpack` CLI from https://github.com/vmware-tanzu/kpack-cli | |
git clone https://github.com/vfarcic/kpack-demo | |
cd kpack-demo | |
kubectl apply \ | |
--filename https://github.com/pivotal/kpack/releases/download/v0.5.3/release-0.5.3.yaml | |
# Replace `[...]` with the registry username | |
export REGISTRY_USER=[...] | |
# Replace `[...]` with the registry password | |
export REGISTRY_PASS=[...] | |
# Replace `https://index.docker.io/v1/` with the registry URL if not using Docker Hub | |
export REGISTRY_URL=https://index.docker.io/v1/ | |
kubectl create namespace build | |
kubectl create secret docker-registry registry-creds \ | |
--docker-username=$REGISTRY_USER \ | |
--docker-password=$REGISTRY_PASS \ | |
--docker-server=$REGISTRY_URL \ | |
--namespace build | |
cat config.yaml \ | |
| sed -e "s@tag: .*@tag: $REGISTRY_USER/silly-demo@g" \ | |
| tee config.yaml | |
cat image.yaml \ | |
| sed -e "s@tag: .*@tag: $REGISTRY_USER/silly-demo@g" \ | |
| sed -e "s@- .*/silly-demo:latest@- $REGISTRY_USER/silly-demo:latest@g" \ | |
| sed -e "s@- .*/silly-demo:0.0.1@- $REGISTRY_USER/silly-demo:0.0.1@g" \ | |
| tee image.yaml | |
kubectl apply --filename config.yaml | |
########################################### | |
# Build Container (Docker) Images Locally # | |
########################################### | |
ls -1 | |
pack build silly-demo | |
# Open https://buildpacks.io | |
docker image ls | |
pack config default-builder \ | |
paketobuildpacks/builder:tiny | |
# Open https://paketo.io | |
pack build silly-demo | |
docker image ls | |
################################################# | |
# Build Container (Docker) Images In Kubernetes # | |
################################################# | |
cat image.yaml | |
kubectl create --filename image.yaml | |
# Open https://github.com/pivotal/kpack | |
kubectl --namespace build get pods | |
kubectl --namespace build get images | |
kp build list --namespace build | |
# Replace `[...]` with the image name | |
export IMAGE=[...] | |
kp build logs $IMAGE --namespace build | |
echo "https://hub.docker.com/r/$REGISTRY_USER/silly-demo/tags" | |
# Open it in a browser | |
############################################# | |
# Build Container (Docker) Images Using CLI # | |
############################################# | |
kp config default-service-account \ | |
registry-creds \ | |
--service-account-namespace build | |
kp image create silly-demo-0-0-2 \ | |
--namespace build \ | |
--builder silly-demo \ | |
--tag vfarcic/silly-demo:0.0.2 \ | |
--git https://github.com/vfarcic/kpack-demo \ | |
--git-revision ebb790f3959c05e6c196e88016a243a0053f450a |
That depends on which container registry you're using. Typically, all should have a UI that show you the info you need to connect to them.
As an alternative, if you logged into your registry with Docker, you should see the info you need in ~/.docker/config.json.
there is an issue with 0.5.4
version btw, as least I can face it: buildpacks-community/kpack#979 otherwise this was a great introduction. thank you for your time doing it.
I did not experience that issue myself. Great that you opened it and hope it'll be resolved soon.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
which url repo should I use instead of dockerhub to build a container image