Skip to content

Commit

Permalink
Improve make compose-up
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-benoit committed Jun 6, 2024
1 parent 01d1bed commit 5dbacf7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 2 additions & 3 deletions templates/node-service/content/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules/
compose.yaml
values.yaml
.score-compose/
.score-compose/
compose.yaml
6 changes: 4 additions & 2 deletions templates/node-service/content/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ WORKLOAD_NAME = node-workload
CONTAINER_NAME = node-service
CONTAINER_IMAGE = ${CONTAINER_NAME}:test

compose.yaml: score.yaml
.score-compose/state.yaml:
score-compose init \
--no-sample

compose.yaml: score.yaml .score-compose/state.yaml Makefile
score-compose generate score.yaml \
--build '${CONTAINER_NAME}={"context":".","tags":["${CONTAINER_IMAGE}"]}' \
--override-property containers.${CONTAINER_NAME}.variables.MESSAGE="Hello, Compose!"
Expand All @@ -26,11 +28,11 @@ compose.yaml: score.yaml
.PHONY: compose-up
compose-up: compose.yaml
docker compose up --build -d --remove-orphans
sleep 5

## 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 $$(score-compose resources get-outputs dns.default#${WORKLOAD_NAME}.dns --format '{{ .host }}:8080')

## Delete the containers running via compose down.
Expand Down
3 changes: 2 additions & 1 deletion templates/podinfo-example/content/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
.score-compose/
compose.yaml
6 changes: 4 additions & 2 deletions templates/podinfo-example/content/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@ WORKLOAD_NAME = podinfo-workload
CONTAINER_NAME = podinfo
CONTAINER_IMAGE = ${CONTAINER_NAME}:test

compose.yaml: score.yaml
.score-compose/state.yaml:
score-compose init \
--no-sample

compose.yaml: score.yaml .score-compose/state.yaml Makefile
score-compose generate score.yaml \
--build '${CONTAINER_NAME}={"context":".","tags":["${CONTAINER_IMAGE}"]}'

## Generate a compose.yaml file from the score spec and launch it.
.PHONY: compose-up
compose-up: compose.yaml
docker compose up --build -d --remove-orphans
sleep 5

## 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 $$(score-compose resources get-outputs dns.default#${WORKLOAD_NAME}.dns --format '{{ .host }}:8080')

## Delete the containers running via compose down.
Expand Down

0 comments on commit 5dbacf7

Please sign in to comment.