docker-compose.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # ------------------------------------------------------------------
  2. # This runs your local FlexMeasures code in a docker compose stack.
  3. # Two FlexMeasures instances are spun up, one for serving the web
  4. # UI & API, one to work on computation jobs.
  5. # The server is adding a toy account when it starts.
  6. # (user: toy-user@flexmeasures.io, password: toy-password)
  7. #
  8. # Instead of local code (which is useful for development purposes),
  9. # you can also use the official (and stable) FlexMeasures docker image
  10. # (lfenergy/flexmeasures). Replace the two `build` directives with
  11. # an `image` directive.
  12. # ------------------------------------------------------------------
  13. services:
  14. dev-db:
  15. image: postgres
  16. expose:
  17. - 5432
  18. restart: always
  19. environment:
  20. POSTGRES_DB: fm-dev-db
  21. POSTGRES_USER: fm-dev-db-user
  22. POSTGRES_PASSWORD: fm-dev-db-pass
  23. volumes:
  24. - ./ci/load-psql-extensions.sql:/docker-entrypoint-initdb.d/load-psql-extensions.sql
  25. queue-db:
  26. image: redis
  27. restart: always
  28. command: redis-server --loglevel warning --requirepass fm-redis-pass
  29. expose:
  30. - 6379
  31. volumes:
  32. - redis-cache:/data
  33. environment:
  34. - REDIS_REPLICATION_MODE=master
  35. mailhog:
  36. image: mailhog/mailhog
  37. ports:
  38. - "1025:1025"
  39. - "8025:8025"
  40. restart: always
  41. server:
  42. build:
  43. context: .
  44. dockerfile: Dockerfile
  45. ports:
  46. - 5000:5000
  47. depends_on:
  48. - dev-db
  49. - test-db # use -e SQLALCHEMY_TEST_DATABASE_URI=... to exec pytest
  50. - queue-db
  51. - mailhog
  52. restart: on-failure
  53. healthcheck:
  54. test: ["CMD", "curl", "-f", "http://localhost:5000/api/v3_0/health/ready"]
  55. start_period: 10s
  56. interval: 20s
  57. timeout: 10s
  58. retries: 6
  59. environment:
  60. SQLALCHEMY_DATABASE_URI: "postgresql://fm-dev-db-user:fm-dev-db-pass@dev-db:5432/fm-dev-db"
  61. SECRET_KEY: notsecret
  62. FLEXMEASURES_ENV: development
  63. FLEXMEASURES_REDIS_URL: queue-db
  64. FLEXMEASURES_REDIS_PASSWORD: fm-redis-pass
  65. MAIL_SERVER: mailhog # MailHog mail server
  66. MAIL_PORT: 1025 # MailHog mail port
  67. LOGGING_LEVEL: INFO
  68. volumes:
  69. # a place for config and plugin code, and custom requirements.txt
  70. # the 1st mount point is for running the FlexMeasures CLI, the 2nd for gunicorn
  71. - ./flexmeasures-instance/:/usr/var/flexmeasures-instance/:ro
  72. - ./flexmeasures-instance/:/app/instance/:ro
  73. entrypoint: ["/bin/sh", "-c"]
  74. command:
  75. - |
  76. pip install -r /usr/var/flexmeasures-instance/requirements.txt
  77. flexmeasures db upgrade
  78. flexmeasures add toy-account --name 'Docker Toy Account'
  79. gunicorn --bind 0.0.0.0:5000 --worker-tmp-dir /dev/shm --workers 2 --threads 4 wsgi:application
  80. worker:
  81. build:
  82. context: .
  83. dockerfile: Dockerfile
  84. depends_on:
  85. - dev-db
  86. - queue-db
  87. - mailhog
  88. restart: on-failure
  89. environment:
  90. SQLALCHEMY_DATABASE_URI: "postgresql://fm-dev-db-user:fm-dev-db-pass@dev-db:5432/fm-dev-db"
  91. FLEXMEASURES_REDIS_URL: queue-db
  92. FLEXMEASURES_REDIS_PASSWORD: fm-redis-pass
  93. SECRET_KEY: notsecret
  94. FLEXMEASURES_ENV: development
  95. MAIL_SERVER: mailhog # MailHog mail server
  96. MAIL_PORT: 1025 # MailHog mail port
  97. LOGGING_LEVEL: INFO
  98. volumes:
  99. # a place for config and plugin code, and custom requirements.txt
  100. - ./flexmeasures-instance/:/usr/var/flexmeasures-instance/:ro
  101. entrypoint: ["/bin/sh", "-c"]
  102. command:
  103. - |
  104. pip install -r /usr/var/flexmeasures-instance/requirements.txt
  105. flexmeasures jobs run-worker --name flexmeasures-worker --queue forecasting\|scheduling
  106. test-db:
  107. image: postgres
  108. expose:
  109. - 5432
  110. restart: always
  111. environment:
  112. POSTGRES_DB: fm-test-db
  113. POSTGRES_USER: fm-test-db-user
  114. POSTGRES_PASSWORD: fm-test-db-pass
  115. volumes:
  116. - ./ci/load-psql-extensions.sql:/docker-entrypoint-initdb.d/load-psql-extensions.sql
  117. volumes:
  118. redis-cache:
  119. driver: local
  120. flexmeasures-instance: