docker-compose.yml 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # A prod-faithful stack in one container, with the box's RAM and CPU as the two
  2. # things you can turn. It exists to answer "would more RAM or more CPU fix this"
  3. # by measurement rather than by argument, so the packages are the PUBLISHED debs
  4. # at versions you name - never a local build - and the data directory is a copy
  5. # of a real one, bind-mounted from outside.
  6. #
  7. # Nothing here is specific to a machine: every path, version and limit comes
  8. # from the environment (see .env.example). Copy that to .env, fill it in, then:
  9. #
  10. # docker compose -f packaging/devstack/docker-compose.yml build
  11. # docker compose -f packaging/devstack/docker-compose.yml up
  12. #
  13. # The limits are enforced by the kernel, not requested: `docker stats` and
  14. # /sys/fs/cgroup inside the container both report them, which is what makes a
  15. # measurement taken here a statement about a box of that size.
  16. services:
  17. devstack:
  18. build:
  19. context: .
  20. dockerfile: Dockerfile
  21. args:
  22. # Which debs the image installs. Point DEB_DIR at a directory holding
  23. # them and name the versions; the build copies exactly these, so the
  24. # artefact under test is the artefact prod runs.
  25. DB_VERSION: ${DB_VERSION:?set DB_VERSION, e.g. 2.21.2-1}
  26. DB_CLIENT_VERSION: ${DB_CLIENT_VERSION:?set DB_CLIENT_VERSION, e.g. 2.20.0-1}
  27. VAPI_VERSION: ${VAPI_VERSION:?set VAPI_VERSION, e.g. 0.18.0-1}
  28. image: svapi-devstack:${VAPI_VERSION}-db${DB_VERSION}
  29. # The whole point of the file, and it takes BOTH settings to model a small
  30. # box. `cpus` is a CPU-time quota: it bounds throughput correctly, but the
  31. # container still SEES every host core, so `nproc` reported 32 on a
  32. # 2-core quota - and cpp-httplib sizes its request pool from
  33. # hardware_concurrency, so vectorapi would run 31 threads where a real
  34. # 2-core box runs 8. Measured, not assumed. `cpuset` pins the container to
  35. # named cores so the COUNT is right as well as the quota, which is what
  36. # makes a concurrency measurement here mean anything.
  37. cpus: ${DEVSTACK_CPUS:-2}
  38. cpuset: ${DEVSTACK_CPUSET:-0-1}
  39. mem_limit: ${DEVSTACK_MEM:-4g}
  40. # Equal to mem_limit asks for NO swap, because a figure measured with swap
  41. # available is a figure about swap. Verify it rather than trusting it:
  42. # `docker inspect --format {{.HostConfig.MemorySwap}}` reported -1
  43. # (unlimited) here even with this set, and what actually guaranteed no
  44. # swapping was the HOST having no swap device - check `swapon --show`
  45. # before reading any memory result off this container.
  46. memswap_limit: ${DEVSTACK_MEMSWAP:-${DEVSTACK_MEM:-4g}}
  47. volumes:
  48. # A COPY of a data directory, never a live one. Read-write, because the
  49. # server replays its WAL and writes snapshots.
  50. - ${DEVSTACK_DATA_DIR:?set DEVSTACK_DATA_DIR to a copy of a data directory}:/var/lib/smartbotic-database
  51. # The database's own config, so the stack under test has the same memory
  52. # budget and eviction thresholds as the deployment being modelled.
  53. - ${DEVSTACK_DB_CONFIG:?set DEVSTACK_DB_CONFIG}:/etc/smartbotic-database/config.json:ro
  54. - ${DEVSTACK_DB_CONFD:?set DEVSTACK_DB_CONFD}:/etc/smartbotic-database/conf.d:ro
  55. ports:
  56. - "${DEVSTACK_PORT:-8099}:8080"
  57. environment:
  58. # Only consulted on a FRESH store. With a copied data directory the keys
  59. # already exist, so this seeds nothing and the real keys keep working.
  60. SMARTBOTIC_VECTORAPI_KEY: ${SMARTBOTIC_VECTORAPI_KEY:-}
  61. stop_grace_period: 120s