docker-compose.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: ./vote
  7. # use python rather than gunicorn for local dev
  8. command: python app.py
  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:/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 server.js
  29. depends_on:
  30. db:
  31. condition: service_healthy
  32. volumes:
  33. - ./result:/app
  34. ports:
  35. - "5001:80"
  36. - "5858:5858"
  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. ports: ["6379"]
  58. networks:
  59. - back-tier
  60. db:
  61. image: postgres:15-alpine
  62. environment:
  63. POSTGRES_USER: "postgres"
  64. POSTGRES_PASSWORD: "postgres"
  65. volumes:
  66. - "db-data:/var/lib/postgresql/data"
  67. - "./healthchecks:/healthchecks"
  68. healthcheck:
  69. test: /healthchecks/postgres.sh
  70. interval: "5s"
  71. networks:
  72. - back-tier
  73. # this service runs once to seed the database with votes
  74. # it won't run unless you specify the "seed" profile
  75. # docker compose --profile seed up -d
  76. seed:
  77. build: ./seed-data
  78. profiles: ["seed"]
  79. depends_on:
  80. vote:
  81. condition: service_healthy
  82. networks:
  83. - front-tier
  84. restart: "no"
  85. volumes:
  86. db-data:
  87. networks:
  88. front-tier:
  89. back-tier: