96 lines
3.1 KiB
Makefile
96 lines
3.1 KiB
Makefile
K8S_VERSION = v1.26.3
|
|
KUBECONFIG = $(PWD)/.kubeconfig
|
|
CLUSTER = $(shell kind get clusters | grep 'bh-local')
|
|
GOBIN = $(shell go env GOPATH)/bin
|
|
|
|
|
|
.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)
|
|
|
|
|
|
SERVICE = "catalog"
|
|
ORIGIN = "https://barretthousen.com"
|
|
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)
|
|
|
|
.PHONY: build-client-image
|
|
build-client-image:
|
|
docker build \
|
|
--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 'origin=$(ORIGIN)' \
|
|
-t barretthousen/client-$(SERVICE):$(VERSION) \
|
|
-t git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION) \
|
|
-f ./src/$(SERVICE)/Dockerfile.frontend ./src/$(SERVICE)
|
|
docker push git.vdhsn.com/barretthousen/client-$(SERVICE):$(VERSION)
|
|
|
|
.PHONY: build-backend-image
|
|
build-backend-image:
|
|
docker build \
|
|
--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)
|
|
|
|
.PHONY: push-image
|
|
push-image:
|
|
|
|
|
|
.PHONY: acceptance-test
|
|
acceptance-test:
|
|
docker run -it --rm \
|
|
-v $(pwd)/src/acceptance-tests.yml:/tests/tests.yml \
|
|
-e "TEST_HOST=bh.localhost" \
|
|
-e "TEST_ENV=local" \
|
|
nytimes/httptest
|
|
|
|
.PHONY: gen
|
|
gen: $(GOBIN)/sqlc buf.lock
|
|
@$(GOBIN)/sqlc generate -f ./src/sqlc.yaml
|
|
@cd ./src && $(GOBIN)/buf generate
|
|
|
|
|
|
.PHONY: setup
|
|
setup: $(GOBIN)/sqlc $(GOBIN)/buf ./env/beta/.age.txt
|
|
@asdf install || true
|
|
|
|
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/beta/master.json)
|
|
./env/beta/.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!"
|