Skip to content

Instantly share code, notes, and snippets.

@lrvick
Last active August 16, 2019 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrvick/63898e6bcf960bbf72c2c7ce5812813e to your computer and use it in GitHub Desktop.
Save lrvick/63898e6bcf960bbf72c2c7ce5812813e to your computer and use it in GitHub Desktop.
make minikube wrapper for helm chart development
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
userid = $(shell id -u)
groupid = $(shell id -g)
image = "local/$(current_dir):latest"
default: build
lint: helm-lint
fetch: submodule-update
latest: submodule-latest build
shell: minikube-start image
@$(contain) shell
build: minikube-start fetch image
mkdir build/tools && \
docker cp $(image):/usr/local/bin/* build/tools/
contain := \
eval $$(build/tools/minikube docker-env) && \
minikube ssh docker run \
-it \
--rm \
--privileged \
-h "$(current_dir)" \
-v $(PWD)/charts:/home/build/charts \
-v $(PWD)/packages:/home/build/packages \
-v $(PWD)/scripts:/home/build/scripts \
-u $(userid):$(groupid) \
$(image)
minikube := \
$(PWD)/build/tools/minikube -p "$(current_dir)"
tools:
mkdir -p build/tools && \
docker cp
minikube-start: minikube-install
$(minikube) start
( $(minikube) mount $(PWD):/home/docker/$(current_dir) & )
minikube-stop:
$(minikube) stop
minikube-shell:
@$(minikube) ssh
minikube-install:
$(PWD)/scripts/minikube-install.sh
image:
$(minikube) ssh "cd $(current_dir) && docker build \
--build-arg UID=$(userid) \
--build-arg GID=$(groupid) \
-t $(image) ."
submodule-update:
git submodule update --init --recursive
submodule-latest:
git submodule foreach 'git checkout master && git pull'
helm-lint:
helm lint charts/*/
clean: minikube-stop
$(minikube) delete
rm -rf build
.DEFAULT_GOAL := default
.PHONY: lint build fetch latest shell contain image submodule-update submodule-latest shell helm-lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment