-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
169 lines (161 loc) · 5.32 KB
/
Copy pathdocker-compose.yml
File metadata and controls
169 lines (161 loc) · 5.32 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
services:
backend:
build: ./backend #custom container, must contine its own Dockerfile
container_name: alpha-backend
ports:
- "8000:8000"
volumes:
- ./backend:/app
depends_on:
postgres:
condition: service_healthy #backend waits for db, basically starts only when the postgres is ready to accept connection
opensearch:
condition: service_healthy
redis:
condition: service_healthy
environment:
- DATABASE_URL=postgresql://admin:admin@postgres:5432/alpha
- OPENSEARCH_HOST=http://opensearch:9200
- GROQ_API_KEY=${GROQ_API_KEY}
- REDIS_URL=redis://redis:6379
- LANGCHAIN_API_KEY=${LANGCHAIN_API_KEY}
- LANGCHAIN_TRACING_V2=true
- LANGCHAIN_PROJECT=alphasignal
env_file:
- .env
postgres:
image: postgres:16 #prebuilt image
container_name: alpha-postgres
environment: #hardcoded the creds right now but in production we will use envs
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
POSTGRES_DB: alpha
env_file:
- .env
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data #db wont reset on restart
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql #this will run the init.sql script when the container starts, allowing us to set up our database schema and initial data automatically
healthcheck:
test: ["CMD-SHELL", "pg_isready -U admin -d alpha"]
interval: 5s
timeout: 5s
retries: 5
opensearch:
image: opensearchproject/opensearch:2.11.0 #prebuilt image
container_name: alpha-opensearch
environment:
- discovery.type=single-node
- plugins.security.disabled=true
- OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
env_file:
- .env
ports:
- "9200:9200"
volumes:
- opensearch_data:/usr/share/opensearch/data
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:9200/_cluster/health || exit 1"]
interval: 10s
timeout: 5s
retries: 5
airflow-init: #just a one time setup container
build: ./airflow #custom image, must contain its own Dockerfile. because we need dependencies like psycopg2 and yfinance
container_name: alpha-airflow-init
depends_on:
postgres:
condition: service_healthy
environment:
- AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://admin:admin@postgres:5432/airflow
- AIRFLOW__CORE__FERNET_KEY=${AIRFLOW__CORE__FERNET_KEY} #takes the encryption key from the .env
- AIRFLOW__CORE__LOAD_EXAMPLES=false #prevents lame demos
env_file:
- .env
command: bash -c "airflow db migrate && airflow users create -u admin -p admin -f Alpha -l Signal -r Admin -e admin@alphasignal.com"
restart: on-failure
airflow-webserver:
build: ./airflow
container_name: alpha-airflow-webserver
depends_on:
postgres:
condition: service_healthy
airflow-init:
condition: service_completed_successfully
ports:
- "8080:8080"
volumes:
- ./airflow/dags:/opt/airflow/dags
- airflow_logs:/opt/airflow/logs
environment:
- AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://admin:admin@postgres:5432/airflow
- AIRFLOW__CORE__FERNET_KEY=${AIRFLOW__CORE__FERNET_KEY}
- AIRFLOW__CORE__LOAD_EXAMPLES=false
- AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.basic_auth
- AIRFLOW__WEBSERVER__SECRET_KEY=${AIRFLOW__CORE__FERNET_KEY}
env_file:
- .env
command: webserver
restart: unless-stopped
airflow-scheduler:
build: ./airflow
container_name: alpha-airflow-scheduler
depends_on:
postgres:
condition: service_healthy
airflow-init:
condition: service_completed_successfully
volumes:
- ./airflow/dags:/opt/airflow/dags
- airflow_logs:/opt/airflow/logs
environment:
- AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://admin:admin@postgres:5432/airflow
- AIRFLOW__CORE__FERNET_KEY=${AIRFLOW__CORE__FERNET_KEY}
- AIRFLOW__CORE__LOAD_EXAMPLES=false
- AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.basic_auth
env_file:
- .env
command: scheduler
restart: unless-stopped
telegram-poller:
build: ./airflow
container_name: alpha-telegram-poller
depends_on:
airflow-webserver:
condition: service_started
airflow-scheduler:
condition: service_started
backend:
condition: service_started
environment:
- TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN}
- TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID}
- BACKEND_URL=http://backend:8000
- AIRFLOW_API_URL=http://airflow-webserver:8080/api/v1
- AIRFLOW_API_USER=admin
- AIRFLOW_API_PASS=admin
- GROQ_API_KEY=${GROQ_API_KEY}
env_file:
- .env
volumes:
- ./airflow/dags:/opt/airflow/dags
- airflow_logs:/opt/airflow/logs
command: python /opt/airflow/dags/telegram_agent.py --poll
restart: unless-stopped
redis:
image: redis/redis-stack-server:latest
container_name: alpha-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
volumes:
postgres_data:
opensearch_data:
airflow_logs:
redis_data: