From d9d0047f68fbe0ad66595441de35eed033eb9083 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 20 Apr 2024 18:22:40 +0000 Subject: [PATCH] Makefile + score-compose --- .gitignore | 4 +- .score-compose/00-service.provisioners.yaml | 7 +++ Makefile | 51 +++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .score-compose/00-service.provisioners.yaml create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index c6f9a44..562b981 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -.vscode/settings.json +.score-compose/* +!.score-compose/00-service.provisioners.yaml +compose.yaml diff --git a/.score-compose/00-service.provisioners.yaml b/.score-compose/00-service.provisioners.yaml new file mode 100644 index 0000000..a8bc855 --- /dev/null +++ b/.score-compose/00-service.provisioners.yaml @@ -0,0 +1,7 @@ +- uri: template://service-provisioners/static-service + type: service + init: | + name: {{ splitList "." .Id | last }} + outputs: | + {{ $w := (index .WorkloadServices .Init.name) }} + name: {{ $w.ServiceName | quote }} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..61fef12 --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +# Disable all the default make stuff +MAKEFLAGS += --no-builtin-rules +.SUFFIXES: + +## Display a list of the documented make targets +.PHONY: help +help: + @echo Documented Make targets: + @perl -e 'undef $$/; while (<>) { while ($$_ =~ /## (.*?)(?:\n# .*)*\n.PHONY:\s+(\S+).*/mg) { printf "\033[36m%-30s\033[0m %s\n", $$2, $$1 } }' $(MAKEFILE_LIST) | sort + +.PHONY: .FORCE +.FORCE: + +compose.yaml: + score-compose init \ + --no-sample + score-compose generate \ + apps/adservice/score.yaml \ + apps/cartservice/score.yaml \ + apps/checkoutservice/score.yaml \ + apps/currencyservice/score.yaml \ + apps/emailservice/score.yaml \ + apps/frontend/score.yaml \ + apps/paymentservice/score.yaml \ + apps/productcatalogservice/score.yaml \ + apps/recommendationservice/score.yaml + apps/shippingservice/score.yaml + +## Generate a compose.yaml file from the score specs and launch it. +.PHONY: compose-up +compose-up: compose.yaml + docker compose up --build -d --remove-orphans + +## Generate a compose.yaml file from the score spec, launch it and test (curl) the exposed container. +.PHONY: compose-test +compose-test: compose-up + sleep 5 + curl localhost:8080 + +## Delete the containers running via compose down. +.PHONY: compose-down +compose-down: + docker compose down -v --remove-orphans || true + +## Deploy the workloads to Humanitec. +.PHONY: humanitec-deploy +humanitec-deploy: + humctl score deploy \ + --deploy-config apps/score.deploy.yaml \ + --env ${HUMANITEC_ENVIRONMENT} \ + --app ${HUMANITEC_APPLICATION} \ No newline at end of file