-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathdocker-compose.yml
122 lines (120 loc) · 3.96 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# ------------------------------------------------------------------
# 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: [email protected], 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: