From 8096a291e6febef5025298543f3af314c71529aa Mon Sep 17 00:00:00 2001 From: ducoterra Date: Mon, 13 Dec 2021 12:58:40 -0500 Subject: [PATCH] Squashed '.gitlab/' changes from cf41f2e..16ee2f3 16ee2f3 Merge branch 'various-docker-fixes' into 'main' 5b3e196 fix docker build and remove release 4bf9d45 Merge branch 'prefix-docker-commands' into 'main' 91b77b3 don't reset head after subtree pull, it breaks things 66b4362 prefix all docker commands with docker- ba2827a Merge branch 'allow-specify-branch' into 'main' 4de5558 ignore .gitlab 71ff227 Allow pulling specific branch with BRANCH_NAME 6430416 Merge branch 'add-helm-and-kube' into 'main' bce675f Add install, upgrade, and uninstall for helm 1532f30 Add kubectl.makefile git-subtree-dir: .gitlab git-subtree-split: 16ee2f3ddcc1235cb4a6b7a38c82d52859e8408f --- .gitignore | 1 + Makefile | 5 ++++- make/docker.makefile | 32 +++++++++++++------------------- make/helm.makefile | 12 ++++++++++++ make/kubectl.makefile | 11 +++++++++++ 5 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 .gitignore create mode 100644 make/kubectl.makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3bbaaed --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.gitlab diff --git a/Makefile b/Makefile index c71a072..f5ca9c1 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,16 @@ IMAGE ?= $(shell cat IMAGE):$(VERSION) IMAGE_LATEST ?= $(shell cat IMAGE):latest PWD ?= $(shell pwd) STASH ?= "common-update-stash" +MAKE_BRANCH ?= main include .gitlab/make/docker.makefile include .gitlab/make/helm.makefile include .gitlab/make/kaniko.makefile include .gitlab/make/truenas.makefile include .gitlab/make/git.makefile +include .gitlab/make/kubectl.makefile +# git subtree add --prefix .gitlab --squash --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git main .PHONY: make-update make-update: - @git subtree pull --prefix .gitlab --squash --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git main + @git subtree pull --prefix .gitlab --squash --message "Merge update from Common" -q git@gitlab.ducoterra.net:services/common.git $(MAKE_BRANCH) diff --git a/make/docker.makefile b/make/docker.makefile index 23e4a52..08fa671 100644 --- a/make/docker.makefile +++ b/make/docker.makefile @@ -3,27 +3,21 @@ docker-init: @touch VERSION @touch IMAGE -.PHONY: buildx-context -buildx-context: - docker buildx create --name container-builder --use --platform linux/amd64,linux/arm64 +.PHONY: docker-buildx-context +docker-buildx-context: + @docker buildx create --name container-builder --use --platform linux/amd64,linux/arm64 -.PHONY: buildx-clear -buildx-clear: - docker buildx rm container-builder +.PHONY: docker-buildx-clear +docker-buildx-clear: + @docker buildx rm container-builder -.PHONY: build -build: - docker buildx build --load . -t $(IMAGE) - @docker buildx build --load . -t $(IMAGE_LATEST) +.PHONY: docker-build +docker-build: + docker build . -t $(IMAGE) -.PHONY: push -push: - -make buildx-clear - @make buildx-context +.PHONY: docker-push +docker-push: + -make docker-buildx-clear + @make docker-buildx-context docker buildx build --platform linux/amd64,linux/arm64 --push . -t $(IMAGE) @docker buildx build --platform linux/amd64,linux/arm64 --push . -t $(IMAGE_LATEST) - -.PHONY: docker-release -docker-release: - @yq e ".services.minecraft.image = \"$(IMAGE)\"" -i docker-compose.yaml - @make push diff --git a/make/helm.makefile b/make/helm.makefile index f603af4..0ecdbea 100644 --- a/make/helm.makefile +++ b/make/helm.makefile @@ -2,3 +2,15 @@ helm-release: @yq e ".version = \"$(shell cat VERSION)\"" -i helm/Chart.yaml @yq e ".appVersion = \"$(shell cat VERSION)\"" -i helm/Chart.yaml + +.PHONY: install +install: set-namespace + helm install $(PROJECT_NAME) ./helm --set image=$(IMAGE) + +.PHONY: upgrade +upgrade: set-namespace + helm upgrade $(PROJECT_NAME) ./helm --set image=$(IMAGE) + +.PHONY: uninstall +uninstall: set-namespace + helm uninstall $(PROJECT_NAME) diff --git a/make/kubectl.makefile b/make/kubectl.makefile new file mode 100644 index 0000000..6077cb5 --- /dev/null +++ b/make/kubectl.makefile @@ -0,0 +1,11 @@ +.PHONY: set-namespace +set-namespace: + kubectl config set contexts.$(shell kubectl config current-context).namespace $(shell cat NAMESPACE) + +.PHONY: create-regcred +create-regcred: + @kubectl create secret docker-registry regcred \ + --docker-server=registry.ducoterra.net \ + --docker-username=$(shell vault kv get -field username secret/duconet/basic-auth) \ + --docker-password='$(shell vault kv get -field password secret/duconet/basic-auth)' \ + --docker-email=$(shell vault kv get -field username secret/duconet/basic-auth)