Skip to content

Commit

Permalink
Makefile + score-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-benoit committed Apr 20, 2024
1 parent c76dc6a commit d9d0047
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.vscode/settings.json
.score-compose/*
!.score-compose/00-service.provisioners.yaml
compose.yaml
7 changes: 7 additions & 0 deletions .score-compose/00-service.provisioners.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit d9d0047

Please sign in to comment.