# ------------------------------------------------------------------ # This runs your local FlexMeasures code in a docker compose stack. # Two FlexMeasures instances are spun up, one for serving the web # UI & API, one to work on computation jobs. # The server is adding a toy account when it starts. # (user: toy-user@flexmeasures.io, password: toy-password) # # Instead of local code (which is useful for development purposes), # you can also use the official (and stable) FlexMeasures docker image # (lfenergy/flexmeasures). Replace the two `build` directives with # an `image` directive. # ------------------------------------------------------------------ services: dev-db: image: postgres expose: - 5432 restart: always environment: POSTGRES_DB: fm-dev-db POSTGRES_USER: fm-dev-db-user POSTGRES_PASSWORD: fm-dev-db-pass volumes: - ./ci/load-psql-extensions.sql:/docker-entrypoint-initdb.d/load-psql-extensions.sql queue-db: image: redis restart: always command: redis-server --loglevel warning --requirepass fm-redis-pass expose: - 6379 volumes: - redis-cache:/data environment: - REDIS_REPLICATION_MODE=master mailhog: image: mailhog/mailhog ports: - "1025:1025" - "8025:8025" restart: always server: build: context: . dockerfile: Dockerfile ports: - 5000:5000 depends_on: - dev-db - test-db # use -e SQLALCHEMY_TEST_DATABASE_URI=... to exec pytest - queue-db - mailhog restart: on-failure healthcheck: test: ["CMD", "curl", "-f", "http://localhost:5000/api/v3_0/health/ready"] start_period: 10s interval: 20s timeout: 10s retries: 6 environment: SQLALCHEMY_DATABASE_URI: "postgresql://fm-dev-db-user:fm-dev-db-pass@dev-db:5432/fm-dev-db" SECRET_KEY: notsecret FLEXMEASURES_ENV: development FLEXMEASURES_REDIS_URL: queue-db FLEXMEASURES_REDIS_PASSWORD: fm-redis-pass MAIL_SERVER: mailhog # MailHog mail server MAIL_PORT: 1025 # MailHog mail port LOGGING_LEVEL: INFO volumes: # a place for config and plugin code, and custom requirements.txt # the 1st mount point is for running the FlexMeasures CLI, the 2nd for gunicorn - ./flexmeasures-instance/:/usr/var/flexmeasures-instance/:ro - ./flexmeasures-instance/:/app/instance/:ro entrypoint: ["/bin/sh", "-c"] command: - | pip install -r /usr/var/flexmeasures-instance/requirements.txt flexmeasures db upgrade flexmeasures add toy-account --name 'Docker Toy Account' gunicorn --bind 0.0.0.0:5000 --worker-tmp-dir /dev/shm --workers 2 --threads 4 wsgi:application worker: build: context: . dockerfile: Dockerfile depends_on: - dev-db - queue-db - mailhog restart: on-failure environment: SQLALCHEMY_DATABASE_URI: "postgresql://fm-dev-db-user:fm-dev-db-pass@dev-db:5432/fm-dev-db" FLEXMEASURES_REDIS_URL: queue-db FLEXMEASURES_REDIS_PASSWORD: fm-redis-pass SECRET_KEY: notsecret FLEXMEASURES_ENV: development MAIL_SERVER: mailhog # MailHog mail server MAIL_PORT: 1025 # MailHog mail port LOGGING_LEVEL: INFO volumes: # a place for config and plugin code, and custom requirements.txt - ./flexmeasures-instance/:/usr/var/flexmeasures-instance/:ro entrypoint: ["/bin/sh", "-c"] command: - | pip install -r /usr/var/flexmeasures-instance/requirements.txt flexmeasures jobs run-worker --name flexmeasures-worker --queue forecasting\|scheduling test-db: image: postgres expose: - 5432 restart: always environment: POSTGRES_DB: fm-test-db POSTGRES_USER: fm-test-db-user POSTGRES_PASSWORD: fm-test-db-pass volumes: - ./ci/load-psql-extensions.sql:/docker-entrypoint-initdb.d/load-psql-extensions.sql volumes: redis-cache: driver: local flexmeasures-instance: