docker-compose.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. version: "3"
  2. services:
  3. # database for master
  4. db_pgsql:
  5. image: postgres:12
  6. environment:
  7. POSTGRES_USER: master_service
  8. POSTGRES_PASSWORD: password
  9. POSTGRES_DB: master_service
  10. volumes:
  11. - pgsql_data:/var/lib/postgresql/data
  12. # database for replica
  13. db_mysql:
  14. image: mysql:8.0
  15. environment:
  16. MYSQL_ROOT_PASSWORD: password
  17. MYSQL_USER: replica_service
  18. MYSQL_PASSWORD: password
  19. MYSQL_DATABASE: replica_service
  20. volumes:
  21. - mysql_data:/var/lib/mysql
  22. command: --default-authentication-plugin=mysql_native_password
  23. # cache storage for replica
  24. redis:
  25. image: redis
  26. # CQRS transport backend
  27. rabbitmq:
  28. image: rabbitmq:3-management-alpine
  29. environment:
  30. RABBITMQ_DEFAULT_USER: rabbitmq
  31. RABBITMQ_DEFAULT_PASS: password
  32. ports:
  33. - 15672:15672
  34. # Domain models provider
  35. master:
  36. build:
  37. context: master_service
  38. ports:
  39. - 8000:8000
  40. depends_on:
  41. - db_pgsql
  42. - rabbitmq
  43. volumes:
  44. - ./master_service:/app
  45. command: >
  46. dockerize -wait tcp://rabbitmq:5672 -timeout 30s
  47. dockerize -wait tcp://db_pgsql:5432 -timeout 30s
  48. ./manage.py runserver 0.0.0.0:8000
  49. # replica WEB app
  50. replica:
  51. build:
  52. context: replica_service
  53. ports:
  54. - 8001:8000
  55. depends_on:
  56. - db_mysql
  57. - redis
  58. - rabbitmq
  59. volumes:
  60. - ./replica_service:/app
  61. command: >
  62. dockerize -wait tcp://rabbitmq:5672 -timeout 30s
  63. dockerize -wait tcp://db_mysql:3306 -timeout 30s
  64. dockerize -wait tcp://redis:6379 -timeout 30s
  65. ./manage.py runserver 0.0.0.0:8000
  66. # replica CQRS consumer worker
  67. replica_cqrs_consumer:
  68. build:
  69. context: replica_service
  70. depends_on:
  71. - db_mysql
  72. - rabbitmq
  73. volumes:
  74. - ./replica_service:/app
  75. command: >
  76. dockerize -wait tcp://rabbitmq:5672 -timeout 30s
  77. dockerize -wait tcp://db_mysql:3306 -timeout 30s
  78. dockerize -wait tcp://redis:6379 -timeout 30s
  79. ./manage.py cqrs_consume -w2
  80. volumes:
  81. pgsql_data:
  82. driver: local
  83. mysql_data:
  84. driver: local