Major optimizations: multi-worker OCR, caching, rate limiting, healthchecks, logging

This commit is contained in:
2026-01-13 13:21:00 -03:00
parent 9b15c7a480
commit d7be8d7036
4 changed files with 202 additions and 102 deletions

View File

@@ -21,6 +21,11 @@ services:
interval: 5s
timeout: 5s
retries: 5
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Backend Service (Node.js)
backend:
@@ -40,28 +45,51 @@ services:
volumes:
- ./backend:/app
- /app/node_modules
healthcheck:
test: [ "CMD", "wget", "-q", "--spider", "http://localhost:3000/api/health" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# ALPR Component (Python + OpenCV)
alpr-service:
build: ./alpr-service
container_name: controlpatente-alpr
ports:
- "5001:5001" # Permite acceder al stream de video desde el nave
- "5001:5001"
environment:
- BACKEND_URL=http://backend:3000
# On Mac, you usually cannot pass /dev/video0 directly.
# We might need to use a stream or just test with a file for now if direct access fails.
# For Linux/Raspberry Pi, the device mapping below is correct.
- PROCESS_INTERVAL=1.5
- DATASET_COOLDOWN=60
- OCR_WORKERS=2
devices:
- "/dev/video0:/dev/video0"
networks:
- backend-net
depends_on:
- backend
backend:
condition: service_healthy
restart: unless-stopped
privileged: true
volumes:
- ./alpr-service/dataset:/app/dataset
healthcheck:
test: [ "CMD", "wget", "-q", "--spider", "http://localhost:5001/health" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
logging:
driver: "json-file"
options:
max-size: "20m"
max-file: "5"
# Frontend Service (React)
frontend:
@@ -78,6 +106,12 @@ services:
environment:
- VITE_API_URL=
- VITE_ALPR_STREAM_URL=
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
networks:
backend-net:
driver: bridge