docker-compose-emqx-cluster.yaml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. version: '3.9'
  2. x-default-emqx: &default-emqx
  3. image: ${_EMQX_DOCKER_IMAGE_TAG}
  4. env_file:
  5. - conf.cluster.env
  6. healthcheck:
  7. test: ["CMD", "/opt/emqx/bin/emqx_ctl", "status"]
  8. interval: 5s
  9. timeout: 25s
  10. retries: 5
  11. services:
  12. haproxy:
  13. container_name: haproxy
  14. image: haproxy:2.4
  15. depends_on:
  16. - emqx1
  17. - emqx2
  18. volumes:
  19. - ./haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
  20. - ../../apps/emqx/etc/certs:/usr/local/etc/haproxy/certs
  21. ports:
  22. - "18083:18083"
  23. # - "1883:1883"
  24. # - "8883:8883"
  25. # - "8083:8083"
  26. # - "8084:8084"
  27. networks:
  28. - emqx_bridge
  29. working_dir: /usr/local/etc/haproxy
  30. command:
  31. - bash
  32. - -c
  33. - |
  34. set -x
  35. cat /usr/local/etc/haproxy/certs/cert.pem /usr/local/etc/haproxy/certs/key.pem > /tmp/emqx.pem
  36. haproxy -f /usr/local/etc/haproxy/haproxy.cfg
  37. emqx1:
  38. <<: *default-emqx
  39. container_name: node1.emqx.io
  40. environment:
  41. - "EMQX_HOST=node1.emqx.io"
  42. networks:
  43. emqx_bridge:
  44. aliases:
  45. - node1.emqx.io
  46. emqx2:
  47. <<: *default-emqx
  48. container_name: node2.emqx.io
  49. environment:
  50. - "EMQX_HOST=node2.emqx.io"
  51. networks:
  52. emqx_bridge:
  53. aliases:
  54. - node2.emqx.io
  55. networks:
  56. emqx_bridge:
  57. driver: bridge
  58. name: emqx_bridge
  59. ipam:
  60. driver: default
  61. config:
  62. - subnet: 172.100.239.0/24
  63. gateway: 172.100.239.1