BASEDIR = $(shell pwd) RULELIST = $(shell gcloud compute forwarding-rules list --format='value[terminator=" "](name)') include Makefile.properties all: cluster app app: db api frontend # Requests a GKE cluster cluster: -gcloud container clusters create $(CLUSTER) --num-nodes $(NODECOUNT) \ --disk-size=$(NODEDISKSIZE) --machine-type=$(NODETYPE) cluster.clean: -gcloud container clusters delete $(CLUSTER) -q pvc.clean: -kubectl delete pvc mysql-pvc-db-set-0 update: api.reset frontend.reset deploy: app.only # Completely obliterates everything. clean: -kubectl delete -f frontend-service.yaml -kubectl delete -f api-service.yaml -kubectl delete -f db-statefulset.yaml -kubectl delete pvc mysql-pvc-db-set-0 -kubectl delete -f db-service.yaml -kubectl delete -f api-deployment.yaml -kubectl delete -f frontend-deployment.yaml sleep 10 -gcloud container clusters delete $(CLUSTER) -q # only gets rid of the container pieces teardown: frontend.teardown api.teardown db.teardown rules.teardown rules.teardown: -gcloud compute forwarding-rules delete $(RULELIST) --region $(REGION) -q app.only: db.service api.service frontend.service db.set api.deployment frontend.deployment app.clean: db.clean api.clean frontend.clean api.teardown: -kubectl delete -f api-deployment.yaml -kubectl delete -f api-service.yaml api.delete.deployment: -kubectl delete -f api-deployment.yaml api.service: kubectl create -f api-service.yaml api.deployment: -kubectl create -f api-deployment.yaml api: api.image api.deployment api.service api.image: api.image.stage api.image.build api.image.unstage api.clean: api.image.unstage api.reset: api.delete.deployment api.image api.deployment api.image.build: docker build -t gcr.io/$(PROJECT)/locations-api "$(BASEDIR)/../containers/api/." gcloud docker push gcr.io/$(PROJECT)/locations-api api.image.stage: cp -R "$(BASEDIR)/../../../code/app" "$(BASEDIR)/../containers/api" rm -rf "$(BASEDIR)/../containers/api/app/ui" rm -rf "$(BASEDIR)/../containers/api/app/static" api.image.unstage: rm -rf "$(BASEDIR)/../containers/api/app" db.teardown: -kubectl delete -f db-statefulset.yaml -kubectl delete -f db-service.yaml db: db.image db.set db.service db.service: kubectl create -f db-service.yaml db.set: kubectl create -f db-statefulset.yaml db.image: db.image.stage db.image.build db.image.unstage db.clean: db.image.unstage db.reset: db.teardown pvc.clean db db.image.build: docker build -t gcr.io/$(PROJECT)/locations-db "$(BASEDIR)/../containers/db/." gcloud docker push gcr.io/$(PROJECT)/locations-db db.image.stage: cp -R "$(BASEDIR)/../../../code/sql" "$(BASEDIR)/../containers/db" cat "$(BASEDIR)/../containers/db/sql/base_schema.sql" > "$(BASEDIR)/../containers/db/sql/load.sql" cat "$(BASEDIR)/../containers/db/sql/starting_data.sql" >> "$(BASEDIR)/../containers/db/sql/load.sql" cat "$(BASEDIR)/../containers/db/sql/creds.sql" >> "$(BASEDIR)/../containers/db/sql/load.sql" db.image.unstage: rm -rf "$(BASEDIR)/../containers/db/sql" frontend: frontend.image frontend.deployment frontend.service frontend.teardown: -kubectl delete -f frontend-deployment.yaml -kubectl delete -f frontend-service.yaml frontend.reset: frontend.delete.deployment frontend.image frontend.deployment frontend.delete.deployment: -kubectl delete -f frontend-deployment.yaml frontend.service: kubectl create -f frontend-service.yaml frontend.deployment: kubectl create -f frontend-deployment.yaml frontend.image: frontend.image.stage frontend.image.build frontend.image.unstage frontend.clean: frontend.image.unstage frontend.image.build: docker build -t gcr.io/$(PROJECT)/locations-frontend "$(BASEDIR)/../containers/frontend/." gcloud docker push gcr.io/$(PROJECT)/locations-frontend frontend.image.stage: cp -R "$(BASEDIR)/../../../code/app/ui" "$(BASEDIR)/../containers/frontend" cp -R "$(BASEDIR)/../../../code/app/static" "$(BASEDIR)/../containers/frontend" frontend.image.unstage: rm -rf "$(BASEDIR)/../containers/frontend/ui" rm -rf "$(BASEDIR)/../containers/frontend/static"