Livrare LOT 1 - Didi

This commit is contained in:
Dezvoltari Evotech 2026-06-25 14:13:25 -07:00
commit 5380c3fc63
990 changed files with 133308 additions and 0 deletions

View file

@ -0,0 +1,43 @@
# syntax=docker/dockerfile:1
# Multi-stage build for the extractors service. Non-root runtime, ffmpeg/ffprobe
# available for video metadata and audio decoding.
FROM python:3.11-slim AS builder
WORKDIR /build
COPY pyproject.toml ./
COPY src ./src
RUN pip install --no-cache-dir --upgrade pip build \
&& pip wheel --no-cache-dir --wheel-dir /wheels ".[ml]"
FROM python:3.11-slim AS runtime
# ffmpeg provides ffmpeg/ffprobe; libgl1/libglib/libxcb are the OpenCV runtime
# libs needed by ultralytics (YOLO).
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ffmpeg \
libgl1 \
libglib2.0-0 \
libxcb1 \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --create-home --uid 10001 appuser
WORKDIR /app
COPY --from=builder /wheels /wheels
RUN pip install --no-cache-dir /wheels/*.whl && rm -rf /wheels
USER appuser
ENV EXTRACTORS_HOST=0.0.0.0 \
EXTRACTORS_PORT=54400
EXPOSE 54400
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request,os,sys; \
url=f'http://127.0.0.1:{os.getenv(\"EXTRACTORS_PORT\",\"54400\")}/health'; \
sys.exit(0 if urllib.request.urlopen(url, timeout=3).status==200 else 1)"
CMD ["sh", "-c", "uvicorn extractors.app:app --host $EXTRACTORS_HOST --port $EXTRACTORS_PORT"]

View file

@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Deploy the extractors service. Fail-fast on missing config (no silent defaults).
set -euo pipefail
cd "$(dirname "$0")"
[[ -f .env ]] && source .env
check_required_var() {
if [[ -z "${!1:-}" ]]; then
echo "ERROR: $1 not set (see .env.example)" >&2
exit 1
fi
}
usage() {
cat <<EOF
Usage: $0 {up|down|logs|build|test}
Required env vars (set in .env):
EXTRACTORS_TAG Image tag (e.g. 0.1.0)
EXTRACTORS_PORT Host/container port (e.g. 54400 dev / 14400 prod)
EXTRACTORS_MAX_UPLOAD_MB Max upload size in MB (e.g. 100)
Optional:
EXTRACTORS_LLM_GATEWAY_URL LLM gateway base URL (sentiment/NER/OCR only)
EXTRACTORS_LLM_MODEL Model alias (default: qwen3.5)
EOF
}
check_required_var "EXTRACTORS_TAG"
check_required_var "EXTRACTORS_PORT"
check_required_var "EXTRACTORS_MAX_UPLOAD_MB"
case "${1:-}" in
up) docker compose up -d --build ;;
down) docker compose down ;;
logs) docker compose logs -f ;;
build) docker compose build ;;
test) docker build -f deploy/Dockerfile --target builder -t extractors-test .. ;;
*) usage; exit 1 ;;
esac

View file

@ -0,0 +1,29 @@
services:
extractors:
build:
context: ..
dockerfile: deploy/Dockerfile
image: extractors:${EXTRACTORS_TAG}
container_name: extractors
restart: unless-stopped
environment:
EXTRACTORS_HOST: "0.0.0.0"
EXTRACTORS_PORT: "${EXTRACTORS_PORT}"
EXTRACTORS_MAX_UPLOAD_MB: "${EXTRACTORS_MAX_UPLOAD_MB}"
# Optional, only needed by sentiment/NER/OCR (added later):
EXTRACTORS_LLM_GATEWAY_URL: "${EXTRACTORS_LLM_GATEWAY_URL:-}"
EXTRACTORS_LLM_MODEL: "${EXTRACTORS_LLM_MODEL:-qwen3.5}"
ports:
- "${EXTRACTORS_PORT}:${EXTRACTORS_PORT}"
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request,os,sys; sys.exit(0 if urllib.request.urlopen(f'http://127.0.0.1:{os.getenv(\"EXTRACTORS_PORT\")}/health',timeout=3).status==200 else 1)"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
networks:
- didi-network
networks:
didi-network:
external: true