Build & Push Docker images inside your Kubernetes cluster
Prerequisites for kubebuild CLI tool
Given the CLI needs access to your Kubernetes cluster to build an image it would require an authenticated context. The CLI tool assumes a working Kubernetes config file at $HOME/.kube/config.
To push the built docker image to your private container registry the CLI tool assumes a valid docker config json at $HOME/.docker/config
Quick run kubebuild CLI
# build the cli for your environment if needed
go build -o kubebuild .
# copy over the executable to your system's bin folder
sudo cp ./kubebuild /usr/local/bin/kubebuild
# See all commands
kubebuild help
# navigate to any local git repo and give the destination docker image tag as an argument (ie, hello/image:v0.0.1)
# NOTE: The builder assumes a Dockerfile is present in the git's origin repository directory
kubebuild build hello/image:v0.0.1
# If successful you should see a 'dockerbuild' job in your cluster
kubectl get jobs
Required Environment Variables for Docker Container