Docker Compose

December 1, 2023 ยท View on GitHub

Below is a compose.yaml including the following services:

docker compose exec db psql postgres postgres

To bring all services up:

docker compose \
       up \
       --detach \
       --remove-orphans

The database will be populated with data loaded from the scripts in this directory.

To check that all services are running OK:

docker compose ps

You can check cached data in pgec with:

curl http://localhost:8080/pub/world_cup_teams_2022/Liberia
{"country": "Liberia",
 "fifth": "Spain",
 "fourth": "Brazil",
 "second": "Argentina",
 "third": "Portugal",
 "top_searched": "Qatar"}

and:

curl http://localhost:8080/pub/xy
{"rows": [{"x":1,"y":"foo"},
          {"x":2,"y":"bar"},
          {"x":4,"y":"boo"},
          {"x":3,"y":"baz"}]}

The database uses a persistent volume called "pgec_db", which can be removed with:

docker volume rm pgec_db

To bring all services down and remove the persistent DB volume:

docker compose \
       down \
       --remove-orphans \
       --volumes