-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
140 lines (139 loc) · 4.86 KB
/
Copy pathdocker-compose.yml
File metadata and controls
140 lines (139 loc) · 4.86 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# ------------------------------------------------------------------
# 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:17
expose:
- 5432
restart: always
environment:
POSTGRES_DB: fm-dev-db
POSTGRES_USER: fm-dev-db-user
POSTGRES_PASSWORD: fm-dev-db-pass
PGDATA: /var/lib/postgresql/data
volumes:
- ./ci/load-psql-extensions.sql:/docker-entrypoint-initdb.d/load-psql-extensions.sql
- ./docker-compose-data/dev-db:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U fm-dev-db-user -d fm-dev-db"]
interval: 10s
timeout: 5s
retries: 3
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
SECURITY_TOTP_SECRETS: '{"1": "something-secret"}'
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
# We use :rw so flexmeasures CLI commands can write log files
- ./flexmeasures-instance/:/usr/var/flexmeasures-instance/:rw
- ./flexmeasures-instance/:/app/instance/:rw
entrypoint: ["/bin/sh", "-c"]
command:
- |
if [ -f /usr/var/flexmeasures-instance/requirements.txt ]; then
pip install --no-cache-dir -r /usr/var/flexmeasures-instance/requirements.txt
fi
flexmeasures db upgrade
if [ ! -f /usr/var/flexmeasures-instance/.toy-account-created ]; then
flexmeasures add toy-account --name 'Docker Toy Account'
touch /usr/var/flexmeasures-instance/.toy-account-created
else
echo "Not creating toy account (already happened once). You can run 'flexmeasures add toy-account' any time."
fi
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
SECURITY_TOTP_SECRETS: '{"1": "something-secret"}'
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/:rw
entrypoint: ["/bin/sh", "-c"]
command:
- |
if [ -f /usr/var/flexmeasures-instance/requirements.txt ]; then
pip install --no-cache-dir -r /usr/var/flexmeasures-instance/requirements.txt
fi
flexmeasures jobs run-worker --name flexmeasures-worker --queue forecasting\|scheduling\|ingestion
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: