Makefile 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. export REGISTRO=harbor.reymota.es\/reymota
  2. #export REGISTRO=registry.reymota.es
  3. export NAMESPACE = finanzas
  4. VERSION_FILE = .version
  5. # Get current version or default to alpine-1
  6. IMG_VERSION := $(shell cat $(VERSION_FILE) 2>/dev/null || echo "alpine-1")
  7. # Get built version for deployment targets
  8. BUILT_VERSION := $(shell cat .current_version 2>/dev/null || echo "$(IMG_VERSION)")
  9. export IMG_VERSION
  10. # limpia todo
  11. all: imagen clean install
  12. imagen:
  13. @echo "Building image with version: $(IMG_VERSION)"
  14. @# Store current version for other targets to use
  15. @echo "$(IMG_VERSION)" > .current_version
  16. cd ../; make
  17. @# Increment version for next build
  18. @echo "$(IMG_VERSION)" | sed 's/alpine-\([0-9]*\)/alpine-\1/' | awk -F'-' '{print "alpine-" $$2+1}' > $(VERSION_FILE)
  19. @echo "Next version will be: $$(cat $(VERSION_FILE))"
  20. ns:
  21. -cat namespace.yaml | sed -e "s/<NS>/${NAMESPACE}/" |kubectl create -f -
  22. install:
  23. -cat reg-secret.yaml| sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  24. -cat env-prod-configmap.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  25. -cat secreto-db.yaml| sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  26. -cat finanzas-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl create -f -
  27. -cat finanzas-service.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  28. -cat finanzas-ingress.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  29. clean:
  30. -cat finanzas-ingress.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  31. -cat finanzas-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl delete -f -
  32. -cat finanzas-service.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  33. -cat secreto-db.yaml| sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  34. -cat env-prod-configmap.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  35. -cat reg-secret.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  36. borraclaims:
  37. -cat pvc-finanzas.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  38. -cat pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  39. claims:
  40. -cat pvc-finanzas.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  41. -cat pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  42. app:
  43. -cat finanzas-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl delete -f -
  44. -cat finanzas-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl create -f -
  45. db:
  46. -kubectl create -f finanzas-db.yaml