-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.standalone.yml
More file actions
307 lines (287 loc) · 9.86 KB
/
Copy pathdocker-compose.standalone.yml
File metadata and controls
307 lines (287 loc) · 9.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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# ========================================
# Lyrebird Standalone Docker Compose
# ========================================
# Self-contained deployment - no repo clone needed!
#
# Usage:
# curl -O https://raw.githubusercontent.com/0-sayed/lyrebird/main/docker-compose.standalone.yml
# docker compose -f docker-compose.standalone.yml up -d
#
# Optional customization with .env file:
# echo "DASHBOARD_PORT=8080" > .env
# docker compose -f docker-compose.standalone.yml up -d
services:
# ========================================
# Infrastructure Services
# ========================================
# PostgreSQL with TimescaleDB Extension
postgres:
image: timescale/timescaledb:latest-pg16
restart: unless-stopped
environment:
POSTGRES_USER: ${DATABASE_USER:-postgres}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD:-lyrebird_secure_password}
POSTGRES_DB: ${DATABASE_NAME:-lyrebird}
POSTGRES_INITDB_ARGS: '-A md5'
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U "$$POSTGRES_USER"']
interval: 10s
timeout: 5s
retries: 5
networks:
- lyrebird-network
# Database initialization via shell command (works in plain docker compose, not just Swarm)
command:
- 'sh'
- '-c'
- |
cat > /docker-entrypoint-initdb.d/init.sql << 'EOSQL'
-- ============================================================
-- Lyrebird Database Schema
-- Must match libs/database/migrations exactly!
-- ============================================================
-- Enable TimescaleDB extension
CREATE EXTENSION IF NOT EXISTS timescaledb;
-- Create jobs table (required for foreign key)
CREATE TABLE IF NOT EXISTS "jobs" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"prompt" text NOT NULL,
"search_strategy" jsonb,
"status" text DEFAULT 'pending' NOT NULL,
"error_message" text,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
"completed_at" timestamp
);
-- Create sentiment_data table with full schema
CREATE TABLE IF NOT EXISTS "sentiment_data" (
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
"job_id" uuid NOT NULL,
"source" text NOT NULL,
"source_url" text,
"author_name" text,
"text_content" text NOT NULL,
"raw_content" text,
"sentiment_score" real NOT NULL,
"sentiment_label" text NOT NULL,
"confidence" real,
"upvotes" integer DEFAULT 0,
"comment_count" integer DEFAULT 0,
"published_at" timestamp NOT NULL,
"collected_at" timestamp DEFAULT now() NOT NULL,
"analyzed_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "sentiment_data_id_published_at_pk" PRIMARY KEY("id","published_at")
);
-- Add foreign key constraint
ALTER TABLE "sentiment_data" ADD CONSTRAINT "sentiment_data_job_id_jobs_id_fk"
FOREIGN KEY ("job_id") REFERENCES "public"."jobs"("id") ON DELETE cascade ON UPDATE no action;
-- Convert to hypertable partitioned by published_at (7-day chunks)
SELECT create_hypertable(
'sentiment_data',
'published_at',
chunk_time_interval => INTERVAL '7 days',
if_not_exists => TRUE
);
-- CRITICAL: Unique index required for ON CONFLICT deduplication
-- TimescaleDB requires unique indexes to include the partitioning column
CREATE UNIQUE INDEX IF NOT EXISTS sentiment_data_job_id_source_url_idx
ON sentiment_data (job_id, source_url, published_at);
-- Additional indexes for query performance
CREATE INDEX IF NOT EXISTS sentiment_data_job_id_idx ON sentiment_data (job_id);
CREATE INDEX IF NOT EXISTS sentiment_data_source_idx ON sentiment_data (source);
CREATE INDEX IF NOT EXISTS sentiment_data_published_at_idx ON sentiment_data (published_at DESC);
CREATE INDEX IF NOT EXISTS sentiment_data_collected_at_idx ON sentiment_data (collected_at DESC);
CREATE INDEX IF NOT EXISTS sentiment_data_sentiment_score_idx ON sentiment_data (sentiment_score);
-- Set up 90-day retention policy
SELECT add_retention_policy(
'sentiment_data',
INTERVAL '90 days',
if_not_exists => TRUE
);
-- Schema initialization complete
-- All tables, indexes, and hypertable configured
EOSQL
exec docker-entrypoint.sh postgres
# RabbitMQ Message Broker
rabbitmq:
image: rabbitmq:4.0-management-alpine
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER:-rabbitmq}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD:-lyrebird_secure_password}
RABBITMQ_DEFAULT_VHOST: ${RABBITMQ_VHOST:-/}
volumes:
- rabbitmq_data:/var/lib/rabbitmq
healthcheck:
test: ['CMD-SHELL', 'rabbitmq-diagnostics -q check_port_listener 5672']
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- lyrebird-network
# Redis Cache
redis:
image: redis:7.4-alpine
restart: unless-stopped
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-lyrebird_secure_password}
volumes:
- redis_data:/data
healthcheck:
test:
[
'CMD-SHELL',
'redis-cli -a "${REDIS_PASSWORD:-lyrebird_secure_password}" ping | grep -q PONG',
]
interval: 10s
timeout: 5s
retries: 5
networks:
- lyrebird-network
# ========================================
# Application Services (from GHCR)
# ========================================
# Gateway Service
gateway:
image: ghcr.io/0-sayed/lyrebird-gateway:${LYREBIRD_VERSION:-latest}
restart: unless-stopped
environment:
NODE_ENV: production
PORT: 3000
DATABASE_HOST: postgres
DATABASE_PORT: 5432
DATABASE_USER: ${DATABASE_USER:-postgres}
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-lyrebird_secure_password}
DATABASE_NAME: ${DATABASE_NAME:-lyrebird}
RABBITMQ_HOST: rabbitmq
RABBITMQ_PORT: 5672
RABBITMQ_USER: ${RABBITMQ_USER:-rabbitmq}
RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD:-lyrebird_secure_password}
RABBITMQ_VHOST: ${RABBITMQ_VHOST:-/}
depends_on:
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
healthcheck:
test:
[
'CMD-SHELL',
'wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1',
]
interval: 30s
timeout: 10s
retries: 5
start_period: 40s
networks:
- lyrebird-network
# Ingestion Service
ingestion:
image: ghcr.io/0-sayed/lyrebird-ingestion:${LYREBIRD_VERSION:-latest}
restart: unless-stopped
environment:
NODE_ENV: production
PORT: 3001
DATABASE_HOST: postgres
DATABASE_PORT: 5432
DATABASE_USER: ${DATABASE_USER:-postgres}
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-lyrebird_secure_password}
DATABASE_NAME: ${DATABASE_NAME:-lyrebird}
RABBITMQ_HOST: rabbitmq
RABBITMQ_PORT: 5672
RABBITMQ_USER: ${RABBITMQ_USER:-rabbitmq}
RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD:-lyrebird_secure_password}
RABBITMQ_VHOST: ${RABBITMQ_VHOST:-/}
JETSTREAM_MAX_DURATION_MS: ${JETSTREAM_MAX_DURATION_MS:-120000}
depends_on:
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
healthcheck:
test:
[
'CMD-SHELL',
'wget --no-verbose --tries=1 --spider http://localhost:3001/health || exit 1',
]
interval: 30s
timeout: 10s
retries: 5
start_period: 40s
networks:
- lyrebird-network
# Analysis Service
analysis:
image: ghcr.io/0-sayed/lyrebird-analysis:${LYREBIRD_VERSION:-latest}
restart: unless-stopped
environment:
NODE_ENV: production
PORT: 3002
DATABASE_HOST: postgres
DATABASE_PORT: 5432
DATABASE_USER: ${DATABASE_USER:-postgres}
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-lyrebird_secure_password}
DATABASE_NAME: ${DATABASE_NAME:-lyrebird}
RABBITMQ_HOST: rabbitmq
RABBITMQ_PORT: 5672
RABBITMQ_USER: ${RABBITMQ_USER:-rabbitmq}
RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD:-lyrebird_secure_password}
RABBITMQ_VHOST: ${RABBITMQ_VHOST:-/}
ML_MODEL_CACHE_DIR: /app/models-cache
ML_QUANTIZATION: ${ML_QUANTIZATION:-q8}
volumes:
- models_cache:/app/models-cache
depends_on:
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
healthcheck:
test:
[
'CMD-SHELL',
'wget --no-verbose --tries=1 --spider http://localhost:3002/health || exit 1',
]
interval: 30s
timeout: 10s
retries: 5
start_period: 40s
networks:
- lyrebird-network
# Dashboard Service
dashboard:
image: ghcr.io/0-sayed/lyrebird-dashboard:${LYREBIRD_VERSION:-latest}
restart: unless-stopped
ports:
- '${DASHBOARD_PORT:-8080}:8080'
depends_on:
gateway:
condition: service_healthy
healthcheck:
test:
[
'CMD-SHELL',
'wget --no-verbose --tries=1 --spider http://127.0.0.1:8080/health || exit 1',
]
interval: 30s
timeout: 10s
retries: 5
start_period: 10s
networks:
- lyrebird-network
# Named volumes for data persistence
volumes:
postgres_data:
driver: local
rabbitmq_data:
driver: local
redis_data:
driver: local
models_cache:
driver: local
# Custom network for service communication
networks:
lyrebird-network:
driver: bridge