You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
barretthousen/Makefile

142 lines
5.2 KiB

K8S_VERSION = v1.26.3
KUBECONFIG = $(PWD)/.kubeconfig
CLUSTER = $(shell kind get clusters | grep 'bh-local')
GOBIN = $(shell go env GOPATH)/bin
###################
# Utilities
###################
.PHONY: setup
setup: $(GOBIN)/sqlc $(GOBIN)/buf
@awk '{ print $$1 }' .tool-versions | xargs -I {} asdf plugin add {} || true
@asdf install || true
@cd ./src/web-client && npm i
@cd ./src/admin-client && npm i
.PHONY: gen
gen: $(GOBIN)/sqlc buf.lock
@$(GOBIN)/sqlc generate -f ./src/sqlc.yaml
@cd ./src && $(GOBIN)/buf generate
.PHONY: dev
dev: .kubeconfig
KUBECONFIG=$(KUBECONFIG) tilt up
.PHONY: clobber
clobber:
KUBECONFIG=$(KUBECONFIG) ctlptl delete registry kind-bh-registry || true
KUBECONFIG=$(KUBECONFIG) ctlptl delete cluster kind-bh-local || true
@rm -f $(KUBECONFIG)
.PHONY: secrets
secrets: ./env/.age.txt
.PHONY: acceptance-test
acceptance-test:
@docker run -it --rm \
-v $(PWD)/src/$(SERVICE)/acceptance-tests.yml:/tests/tests.yml \
-e "TEST_HOST=$(ORIGIN)" \
nytimes/httptest
##############################
# Container Image Building
# see ./doc/deployment.md for details
##############################
SERVICE = "catalog"
ENV ?= ""
BUILD_INITIATOR = "Development Machine"
VERSION = $(shell git rev-parse --verify --short HEAD)
GIT_REF = $(shell git rev-parse --verify HEAD)
BUILD_DATE := $(shell date +%Y-%m-%d-%T)
add catawiki catalog sync, DX improvements, ci - drone ci build using kaniko This builds images extremely slowly, I've implemented some custom fixes to the plugin to improve performance but it's still slow to build images. I will try to implement a DinD solution. There are issues in kaniko about this: https://github.com/GoogleContainerTools/kaniko/issues/875 Squashed commit of the following: commit 1fd65ad139c7ac199d0cf793a5dea07ee71a20a9 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Sat Jul 15 18:17:55 2023 -0500 add deploy script commit 075e15f218c0c81c487fa6362bf5efde8a28c4f4 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Sat Jul 15 17:53:24 2023 -0500 bump limits commit 2d45234e7b4d8c30b03ead01da20359e180f5e2a Author: Adam Veldhousen <adamveld12@gmail.com> Date: Sat Jul 15 17:51:19 2023 -0500 sync button in tilt, support syncing all targets simultaneously commit 75e73a1171a6200b159fe17a3fb40d230ff95c8b Author: Adam Veldhousen <adamveld12@gmail.com> Date: Sat Jul 15 17:03:50 2023 -0500 create admin user on startup commit 40cf74560d39e817b9a474b04f86d2677f6217bc Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 11:14:00 2023 -0500 test more cache commit 1fbbfe7548513185aaad65690b8a4455312bf7f5 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 11:11:34 2023 -0500 test tmpfs commit 0f48c098d9c5ab41cd9bb71066a8447910112c21 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 11:08:32 2023 -0500 add tmpfs commit d37142cfef1d66a13e66c9d8025b32da04710d63 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 11:02:39 2023 -0500 crank verbosity commit 178eb5bc3867f4eb9efe6cf0a3ada2deaf89651e Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 10:44:08 2023 -0500 bump requests commit b0aa0b39f0ff790c552b37fb3c903bc7af476703 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 10:40:04 2023 -0500 test fewer concurrent builds commit 221e378a534d787715c2413019c4f55e65844506 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Thu Jul 13 20:40:18 2023 -0500 test commit 6c03914341dce447251b4fb695fa33c09f2a2858 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Thu Jul 13 19:01:22 2023 -0500 snapshot mode for faster build commit 91c56d430e23477715188591d8af49569aed2dee Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 22:40:12 2023 -0500 try script commit 4a119c252344ded29d45b850b96261153f512a85 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 22:28:41 2023 -0500 test promote commit b1062a40014407872f920e062a02c88c09dc10af Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 22:26:58 2023 -0500 test commit c06804dfe6c3ca1b2508b2ccbf84cc3b20703c2a Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 17:47:48 2023 -0500 beta promote and ignore commit 643e104c372e09707f1047ab32ec9d3ceb973fe3 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 16:21:39 2023 -0500 tweakies commit 478e65ac70a10940b3f291ecd0e874ce46129412 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 16:09:54 2023 -0500 un woops commit 966d48c193b2515bfe43dba778bd5cbf7ae70efc Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 15:23:08 2023 -0500 woops commit 2829743d17c41189ddf38153f44377015f9972b7 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 15:22:03 2023 -0500 test internal routing commit e08e68b8ad1a9fcb0bddef4bb3c09511be795573 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 14:07:31 2023 -0500 push images commit 5705bca0687c50e071ddad8feee7372193cb21f2 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 13:40:48 2023 -0500 ugh commit 1699b08d5f30af5f3a7b9c3b89400d5d978bb7b8 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 13:39:49 2023 -0500 fixup client builds commit 9ec8616ae17cac4701abe5a34de3e3a3b2932ba8 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 13:36:36 2023 -0500 update go mods commit 163b25fd67f48d9a09bdf8916d93e5b3f694b969 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 02:11:02 2023 -0500 fix fronend builds commit e5cc7d5c792dbb17f751dd47c767c85afac25921 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:56:08 2023 -0500 resources commit 8088b95c1ec3fa7048618054db06d0d9c790fd64 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:38:21 2023 -0500 big test commit 38fef91c499f138be706909214e6bce16f6a5b67 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:26:09 2023 -0500 testicles commit 53baa0a6478a6b2340fc29b6ea175fa4f02a7610 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:24:50 2023 -0500 testicles commit 16901ec5bb666174e6549e4278994968850433b7 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:23:38 2023 -0500 testicles commit 3478d4f512b57677a264ada5f2c57a616edf0c3d Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:19:58 2023 -0500 test 2 commit 16298ada7863880dc9830bc99d2e442391b5779c Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:13:53 2023 -0500 more test commit 80524a1d06b1d764b55bed475bf3d5100d1dbc25 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:09:03 2023 -0500 test commit b9916204dea1f499e66a5fb708d78e474b893105 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 00:19:41 2023 -0500 tools image commit 6e414b3a1bcefbbca9912cee30191f0c1c2d5aed Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 00:00:23 2023 -0500 test commit abb6183e887613ab366734cf589ddb23f22cc0e8 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Tue Jul 11 22:55:58 2023 -0500 added catawiki scrape commit 2643817e9396059d3a2cbb655a6b8fa52896adca Author: Adam Veldhousen <adamveld12@gmail.com> Date: Tue Jul 11 14:40:05 2023 -0500 add catawiki syncer
10 months ago
.PHONY: build-tools-image
build-tools-image:
@docker build \
--label 'com.barretthousen.version=$(VERSION)' \
--label 'com.barretthousen.git-ref=$(GIT_REF)' \
--label 'com.barretthousen.build-date=$(BUILD_DATE)' \
--label 'com.barrethousen.builder=$(BUILD_INITIATOR)' \
-t git.vdhsn.com/barretthousen/tools):$(VERSION) \
-t git.vdhsn.com/barretthousen/tools):v1 \
-f ./src/Dockerfile.tools ./src
@docker push git.vdhsn.com/barretthousen/tools:$(VERSION)
@docker push git.vdhsn.com/barretthousen/tools:v1
.PHONY: build-client-image
build-client-image:
@docker build --target=production \
--label 'com.barretthousen.service=$(SERVICE)' \
--label 'com.barretthousen.version=$(VERSION)' \
--label 'com.barretthousen.git-ref=$(GIT_REF)' \
--label 'com.barretthousen.build-date=$(BUILD_DATE)' \
--label 'com.barrethousen.builder=$(BUILD_INITIATOR)' \
--build-arg 'service=$(SERVICE)' \
-t barretthousen/client-$(SERVICE):$(VERSION) \
-t git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION) \
-f ./src/Dockerfile.frontend ./src/$(SERVICE)
@docker push git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION)
11 months ago
@[ ! -z $(ENV) ] && docker tag git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION) git.vdhsn.com/barretthousen/client-$(SERVICE):$(ENV) || true
@[ ! -z $(ENV) ] && docker push git.vdhsn.com/barretthousen/client-$(SERVICE):$(ENV) || true
.PHONY: build-backend-image
build-backend-image:
@docker build --target=production \
--label 'com.barretthousen.service=$(SERVICE)' \
--label 'com.barretthousen.version="$(VERSION)"' \
--label 'com.barretthousen.git-ref="$(GIT_REF)"' \
--label 'com.barretthousen.build-date=$(BUILD_DATE)' \
--label 'com.barrethousen.builder=$(BUILD_INITIATOR)' \
--build-arg 'service=$(SERVICE)' \
-t barretthousen/service-$(SERVICE):$(VERSION) \
-t git.vdhsn.com/barretthousen/service-$(SERVICE):$(VERSION) \
-f ./src/Dockerfile.prod-backend ./src
@docker push git.vdhsn.com/barretthousen/service-$(SERVICE):$(VERSION)
11 months ago
@[ ! -z $(ENV) ] && docker tag git.vdhsn.com/barretthousen/service-$(SERVICE):$(VERSION) git.vdhsn.com/barretthousen/service-$(SERVICE):$(ENV) || true
@[ ! -z $(ENV) ] && docker push git.vdhsn.com/barretthousen/service-$(SERVICE):$(ENV) || true
# TODO: investigate tagging without needing to pull? https://dille.name/blog/2018/09/20/how-to-tag-docker-images-without-pulling-them/
.PHONY: promote-client-prod
promote-client-prod:
@docker pull git.vdhsn.com/barretthousen/client-$(SERVICE):beta
@docker tag git.vdhsn.com/barretthousen/client-$(SERVICE):beta git.vdhsn.com/barretthousen/client-$(SERVICE):prod
@docker push git.vdhsn.com/barretthousen/client-$(SERVICE):prod
.PHONY: promote-backend-prod
promote-backend-prod:
@docker pull git.vdhsn.com/barretthousen/service-$(SERVICE):beta
@docker tag git.vdhsn.com/barretthousen/service-$(SERVICE):beta git.vdhsn.com/barretthousen/service-$(SERVICE):prod
@docker push git.vdhsn.com/barretthousen/service-$(SERVICE):prod
####################
# File targets
####################
buf.lock: $(GOBIN)/buf
@$(GOBIN)/buf mod update ./src
$(GOBIN)/buf:
@go install github.com/bufbuild/buf/cmd/buf@v1.17.0
$(GOBIN)/sqlc:
@go install github.com/kyleconroy/sqlc/cmd/sqlc@latest
.kubeconfig:
@KUBECONFIG=$(KUBECONFIG) ctlptl create registry kind-bh-registry --port=5005
@KUBECONFIG=$(KUBECONFIG) ctlptl create cluster kind --name=kind-bh-local --registry=kind-bh-registry --kubernetes-version $(K8S_VERSION)
@kind get kubeconfig --name=bh-local > .kubeconfig
# used to encrypt/decrypt sensitive values with sops
age_identity=$(shell sops -d ./env/master.json)
./env/.age.txt:
@echo "# created: $(shell echo '$(age_identity)' | jq -r '.created')" >> $@
@echo "# public key: $(shell echo '$(age_identity)' | jq -r '.public_key')" >> $@
@echo "$(shell echo '$(age_identity)' | jq -r '.private_key')" >> $@
@echo "$@ created!"
add catawiki catalog sync, DX improvements, ci - drone ci build using kaniko This builds images extremely slowly, I've implemented some custom fixes to the plugin to improve performance but it's still slow to build images. I will try to implement a DinD solution. There are issues in kaniko about this: https://github.com/GoogleContainerTools/kaniko/issues/875 Squashed commit of the following: commit 1fd65ad139c7ac199d0cf793a5dea07ee71a20a9 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Sat Jul 15 18:17:55 2023 -0500 add deploy script commit 075e15f218c0c81c487fa6362bf5efde8a28c4f4 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Sat Jul 15 17:53:24 2023 -0500 bump limits commit 2d45234e7b4d8c30b03ead01da20359e180f5e2a Author: Adam Veldhousen <adamveld12@gmail.com> Date: Sat Jul 15 17:51:19 2023 -0500 sync button in tilt, support syncing all targets simultaneously commit 75e73a1171a6200b159fe17a3fb40d230ff95c8b Author: Adam Veldhousen <adamveld12@gmail.com> Date: Sat Jul 15 17:03:50 2023 -0500 create admin user on startup commit 40cf74560d39e817b9a474b04f86d2677f6217bc Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 11:14:00 2023 -0500 test more cache commit 1fbbfe7548513185aaad65690b8a4455312bf7f5 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 11:11:34 2023 -0500 test tmpfs commit 0f48c098d9c5ab41cd9bb71066a8447910112c21 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 11:08:32 2023 -0500 add tmpfs commit d37142cfef1d66a13e66c9d8025b32da04710d63 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 11:02:39 2023 -0500 crank verbosity commit 178eb5bc3867f4eb9efe6cf0a3ada2deaf89651e Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 10:44:08 2023 -0500 bump requests commit b0aa0b39f0ff790c552b37fb3c903bc7af476703 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Fri Jul 14 10:40:04 2023 -0500 test fewer concurrent builds commit 221e378a534d787715c2413019c4f55e65844506 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Thu Jul 13 20:40:18 2023 -0500 test commit 6c03914341dce447251b4fb695fa33c09f2a2858 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Thu Jul 13 19:01:22 2023 -0500 snapshot mode for faster build commit 91c56d430e23477715188591d8af49569aed2dee Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 22:40:12 2023 -0500 try script commit 4a119c252344ded29d45b850b96261153f512a85 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 22:28:41 2023 -0500 test promote commit b1062a40014407872f920e062a02c88c09dc10af Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 22:26:58 2023 -0500 test commit c06804dfe6c3ca1b2508b2ccbf84cc3b20703c2a Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 17:47:48 2023 -0500 beta promote and ignore commit 643e104c372e09707f1047ab32ec9d3ceb973fe3 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 16:21:39 2023 -0500 tweakies commit 478e65ac70a10940b3f291ecd0e874ce46129412 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 16:09:54 2023 -0500 un woops commit 966d48c193b2515bfe43dba778bd5cbf7ae70efc Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 15:23:08 2023 -0500 woops commit 2829743d17c41189ddf38153f44377015f9972b7 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 15:22:03 2023 -0500 test internal routing commit e08e68b8ad1a9fcb0bddef4bb3c09511be795573 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 14:07:31 2023 -0500 push images commit 5705bca0687c50e071ddad8feee7372193cb21f2 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 13:40:48 2023 -0500 ugh commit 1699b08d5f30af5f3a7b9c3b89400d5d978bb7b8 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 13:39:49 2023 -0500 fixup client builds commit 9ec8616ae17cac4701abe5a34de3e3a3b2932ba8 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 13:36:36 2023 -0500 update go mods commit 163b25fd67f48d9a09bdf8916d93e5b3f694b969 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 02:11:02 2023 -0500 fix fronend builds commit e5cc7d5c792dbb17f751dd47c767c85afac25921 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:56:08 2023 -0500 resources commit 8088b95c1ec3fa7048618054db06d0d9c790fd64 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:38:21 2023 -0500 big test commit 38fef91c499f138be706909214e6bce16f6a5b67 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:26:09 2023 -0500 testicles commit 53baa0a6478a6b2340fc29b6ea175fa4f02a7610 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:24:50 2023 -0500 testicles commit 16901ec5bb666174e6549e4278994968850433b7 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:23:38 2023 -0500 testicles commit 3478d4f512b57677a264ada5f2c57a616edf0c3d Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:19:58 2023 -0500 test 2 commit 16298ada7863880dc9830bc99d2e442391b5779c Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:13:53 2023 -0500 more test commit 80524a1d06b1d764b55bed475bf3d5100d1dbc25 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 01:09:03 2023 -0500 test commit b9916204dea1f499e66a5fb708d78e474b893105 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 00:19:41 2023 -0500 tools image commit 6e414b3a1bcefbbca9912cee30191f0c1c2d5aed Author: Adam Veldhousen <adamveld12@gmail.com> Date: Wed Jul 12 00:00:23 2023 -0500 test commit abb6183e887613ab366734cf589ddb23f22cc0e8 Author: Adam Veldhousen <adamveld12@gmail.com> Date: Tue Jul 11 22:55:58 2023 -0500 added catawiki scrape commit 2643817e9396059d3a2cbb655a6b8fa52896adca Author: Adam Veldhousen <adamveld12@gmail.com> Date: Tue Jul 11 14:40:05 2023 -0500 add catawiki syncer
10 months ago
@echo "export SOPS_AGE_KEY_FILE=$(PWD)/env/.age.txt"