-
Notifications
You must be signed in to change notification settings - Fork 11
/
docker-compose.yaml
156 lines (147 loc) · 4.39 KB
/
docker-compose.yaml
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
x-common-infos:
# Env variables stored in a .env file at same level than docker-compose.yaml
environment: &common-env
POSTGRES_HOSTNAME: ${POSTGRES_HOSTNAME:-postgres_bloom}
POSTGRES_DB: ${POSTGRES_DB:-bloom_db}
POSTGRES_USER: ${POSTGRES_USER:-bloom_user}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-bloom}
LOGGING_LEVEL: ${LOGGING_LEVEL:-INFO}
services:
bloom-backend:
container_name: bloom_backend
hostname: bloom-backend
image: d4g/bloom-backend:${VERSION:-latest}
working_dir: /project/backend
command:
- bash
- -c
- |
echo "Starting Scheduler" &&
service cron start && uvicorn bloom.app:app --host 0.0.0.0 --reload
volumes:
- ./:/project/
- ./data:/project/data
environment:
<<: *common-env
POSTGRES_PORT: 5432
STREAMLIT_SERVER_ADDRESS: ${STREAMLIT_SERVER_ADDRESS:-0.0.0.0}
REDIS_HOST: bloom-redis
REDIS_PORT: 6379
WATCHFILES_FORCE_POLLING: true
ports:
- ${API_PORT:-8000}:8000
networks:
- bloom_net
depends_on:
bloom-init:
condition: service_completed_successfully
bloom-redis:
image: redis:7-alpine
container_name: bloom_redis
hostname: bloom-redis
restart: always
command:
- sh
- -c
- redis-server --requirepass ${REDIS_PASSWORD}
ports:
- ${REDIS_PORT:-6379}:6379
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD:-redis}
- REDIS_PORT=${REDIS_PORT:-6379}
volumes:
- bloom-redis:/data
networks:
- bloom_net
bloom-postgres:
container_name: postgres_bloom
hostname: bloom-postgres
image: ${POSTGIS_IMAGE:-postgis/postgis:14-3.3-alpine}
environment:
<<: *common-env
ports:
- ${POSTGRES_PORT:-5432}:5432
volumes:
- bloom-data:/var/lib/postgresql/data
networks:
- bloom_net
healthcheck:
# PostGis database initialization is done with two steps (postgres+postgis)
# This causes healthcheck to be valid before real full initialization
# and so causing dependent containers starting before full db initialization
# This lines check 3 consecutive times database status instead of only 1
# This is suffisiant to avoir first valid check and cover full initialization
# If check fails, waiting 5s to recheck, max 3 times and then fails.
test:
[
'CMD-SHELL',
"for i in 1 2 3; do pg_isready --quiet --dbname=$${POSTGRES_DB:-bloom_db} --username=$${POSTGRES_USER:-bloom_user} && break || sleep 5; done"
]
interval: 15s
timeout: 45s
retries: 3
start_period: 0s
bloom-frontend:
container_name: bloom_frontend
hostname: bloom-frontend
image: d4g/bloom-frontend:${VERSION:-latest}
#command: env node ./node_modules/next/dist/bin/next start --hostname 0.0.0.0
#command: npm run dev
#command: yarn dev
command: sh -c "if [ ! -f node_modules/next/dist/bin/next ]; then npm install && npm run build; fi; npm run dev"
tty: true
stdin_open: true
working_dir: /app
build:
context: .
dockerfile: ./docker/frontend/dev.Dockerfile
args:
APP_DIR: /app
volumes:
#- ./frontend:/app
#- ./frontend/node_modules:/app/node_modules
#- ./frontend/.next:/app/.next
- ./data:/app/public/data
# - ./:/project/
- ./data:/project/frontend/public/data
environment:
LOGGING_LEVEL: ${LOGGING_LEVEL:-INFO}
networks:
- bloom_net
ports:
- ${HTTP_PORT:-3000}:3000
depends_on:
bloom-init:
condition: service_completed_successfully
bloom-init:
container_name: bloom_init
hostname: bloom-init
image: d4g/bloom-backend:${VERSION:-latest}
# Nominal start:
command: /bin/bash -c "cd backend;alembic upgrade head"
# Debug start:
#command: bash
#tty: true
#stdin_open: true
build:
context: .
dockerfile: ./docker/Dockerfile
args:
IMAGE_PYTHON: ${IMAGE_PYTHON:-python:3.10-slim-bullseye}
POETRY_VERSION: ${POETRY_VERSION:-1.8.2}
environment:
<<: *common-env
POSTGRES_PORT: 5432
volumes:
- ./:/project/
networks:
- bloom_net
depends_on:
bloom-postgres:
condition: service_healthy # The service is working and still running
volumes:
bloom-data:
bloom-redis:
networks:
bloom_net:
name: bloom_net