Files
sound-analyze/docker-compose.yml

109 lines
2.5 KiB
YAML

services:
db:
image: timescale/timescaledb:2.13.1-pg16
container_name: audio_timescaledb
environment:
POSTGRES_DB: ${DB_NAME:-audio_analyzer}
POSTGRES_USER: ${DB_USER:-postgres}
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
volumes:
- timescale_data:/var/lib/postgresql/data
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
ports:
- "${DB_PORT:-5432}:5432"
networks:
- audio_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
collector:
build:
context: ./services/collector
dockerfile: Dockerfile
container_name: audio_collector
depends_on:
db:
condition: service_healthy
environment:
SERIAL_PORT: ${SERIAL_PORT:-/dev/ttyACM0}
BAUDRATE: ${BAUDRATE:-115200}
DB_HOST: db
DB_PORT: 5432
DB_NAME: ${DB_NAME:-audio_analyzer}
DB_USER: ${DB_USER:-postgres}
DB_PASSWORD: ${DB_PASSWORD:-postgres}
WS_HOST: 0.0.0.0
WS_PORT: 8000
ports:
- "8001:8000"
devices:
- "${SERIAL_PORT:-/dev/ttyACM0}:${SERIAL_PORT:-/dev/ttyACM0}"
networks:
- audio_network
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
api:
build:
context: ./services/api
dockerfile: Dockerfile
container_name: audio_api
depends_on:
db:
condition: service_healthy
environment:
DATABASE_URL: postgresql+asyncpg://postgres:postgres@db:5432/audio_analyzer
ports:
- "8000:8000"
volumes:
- ./services/api:/app
networks:
- audio_network
healthcheck:
test:
[
"CMD-SHELL",
"curl --fail http://localhost:8000/api/v1/health/live || exit 1",
]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
frontend:
build:
context: ./services/frontend
dockerfile: Dockerfile
container_name: audio_frontend_dev
ports:
- "3000:5173"
environment:
VITE_API_URL: http://localhost:8000
VITE_WS_URL: ws://localhost:8001/ws/live
# VITE_API_URL: http://api:8000
# VITE_WS_URL: ws://api:8001
volumes:
- ./services/frontend:/app
- /app/node_modules
networks:
- audio_network
stdin_open: true
tty: true
restart: unless-stopped
volumes:
timescale_data:
driver: local
networks:
audio_network:
driver: bridge