Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
82 lines (79 loc) · 2.61 KB
/
Copy pathdocker-compose.yml
File metadata and controls
82 lines (79 loc) · 2.61 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
services:
db:
image: realestatesearch-db:local # postgis + pgvector (see Dockerfile.db)
build:
context: .
dockerfile: Dockerfile.db
# Memory tuning (2026-09-17): the default 128 MB shared_buffers gave a 55% cache
# hit ratio against ~900 MB of hot data. Sized per host via .env
# (PG_SHARED_BUFFERS / PG_EFFECTIVE_CACHE_SIZE / PG_WORK_MEM); defaults suit a
# small dev box, the VPS sets 2GB / 5GB / 16MB.
command:
- postgres
- -c
- shared_buffers=${PG_SHARED_BUFFERS:-512MB}
- -c
- effective_cache_size=${PG_EFFECTIVE_CACHE_SIZE:-2GB}
- -c
- work_mem=${PG_WORK_MEM:-8MB}
# Parallel hash joins allocate in /dev/shm; Docker's 64 MB default fails those
# queries ("No space left on device") once work_mem is raised. Used on demand only.
shm_size: 1gb
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- "5433:5432"
volumes:
- pgdata:/var/lib/postgresql/data
- ./schema/postgresql.sql:/docker-entrypoint-initdb.d/01-schema.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U admin -d real_estate"]
interval: 2s
timeout: 5s
retries: 15
app:
image: realestatesearch:local
build: .
ports:
- "8888:8888"
env_file:
- .env
volumes:
- ./log:/app/log
environment:
POSTGRES_HOST: db
POSTGRES_PORT: 5432
depends_on:
db:
condition: service_healthy
restart: unless-stopped
healthcheck:
# Hits /health, which runs SELECT count(*) FROM properties — so this also
# verifies the DB pool is alive, not just that uvicorn responds.
test: ["CMD", "python", "-c", "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8888/health', timeout=3).status == 200 else 1)"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
# Background processor — drains raw_properties → primary tables.
# Runs in its own container so the web tier (app) never competes with
# the Vision API for connections or CPU. Same image + build context as `app`,
# so Compose dedups the build into a single image. NOT dependent on `app`
# at runtime — the worker only needs the database.
worker:
image: realestatesearch:local
build: .
command: ["python", "-m", "src.img_analyzer.worker_main"]
env_file:
- .env
environment:
POSTGRES_HOST: db
POSTGRES_PORT: 5432
depends_on:
db:
condition: service_healthy
restart: unless-stopped
volumes:
pgdata: