docker-compose.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # version is now using "compose spec"
  2. # v2 and v3 are now combined!
  3. # docker-compose v1.27+ required
  4. services:
  5. vote:
  6. build:
  7. context: ./vote
  8. target: dev
  9. depends_on:
  10. redis:
  11. condition: service_healthy
  12. healthcheck:
  13. test: ["CMD", "curl", "-f", "http://localhost"]
  14. interval: 15s
  15. timeout: 5s
  16. retries: 3
  17. start_period: 10s
  18. volumes:
  19. - ./vote:/usr/local/app
  20. ports:
  21. - "5000:80"
  22. networks:
  23. - front-tier
  24. - back-tier
  25. result:
  26. build: ./result
  27. # use nodemon rather than node for local dev
  28. entrypoint: nodemon --inspect=0.0.0.0 server.js
  29. depends_on:
  30. db:
  31. condition: service_healthy
  32. volumes:
  33. - ./result:/usr/local/app
  34. ports:
  35. - "5001:80"
  36. - "127.0.0.1:9229:9229"
  37. networks:
  38. - front-tier
  39. - back-tier
  40. worker:
  41. build:
  42. context: ./worker
  43. depends_on:
  44. redis:
  45. condition: service_healthy
  46. db:
  47. condition: service_healthy
  48. networks:
  49. - back-tier
  50. redis:
  51. image: redis:alpine
  52. volumes:
  53. - "./healthchecks:/healthchecks"
  54. healthcheck:
  55. test: /healthchecks/redis.sh
  56. interval: "5s"
  57. networks:
  58. - back-tier
  59. db:
  60. image: postgres:15-alpine
  61. environment:
  62. POSTGRES_USER: "postgres"
  63. POSTGRES_PASSWORD: "postgres"
  64. volumes:
  65. - "db-data:/var/lib/postgresql/data"
  66. - "./healthchecks:/healthchecks"
  67. healthcheck:
  68. test: /healthchecks/postgres.sh
  69. interval: "5s"
  70. networks:
  71. - back-tier
  72. # this service runs once to seed the database with votes
  73. # it won't run unless you specify the "seed" profile
  74. # docker compose --profile seed up -d
  75. seed:
  76. build: ./seed-data
  77. profiles: ["seed"]
  78. depends_on:
  79. vote:
  80. condition: service_healthy
  81. networks:
  82. - front-tier
  83. restart: "no"
  84. volumes:
  85. db-data:
  86. networks:
  87. front-tier:
  88. back-tier: