From ea1904f9af129f49f6e41ae6c2aa9d5eaa4db4de Mon Sep 17 00:00:00 2001 From: keboss-m <85340750+keboss-m@users.noreply.github.com> Date: Sun, 31 May 2026 13:04:13 +0300 Subject: [PATCH] Fix Docker: correct entrypoint, remove hf_cache volume overlap, use existing image with models --- .dockerignore | 1 + .gitattributes | 14 ++++++++++++++ Dockerfile | 21 +++------------------ docker-compose.yml | 10 ++++------ 4 files changed, 22 insertions(+), 24 deletions(-) create mode 100644 .gitattributes diff --git a/.dockerignore b/.dockerignore index 652584a..c0cc70f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -37,6 +37,7 @@ video/ *.docx *.md *.txt +!requirements.txt # IDE .vscode/ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5e0048e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +* text=auto eol=lf +*.sh text eol=lf +*.py text eol=lf +*.yml text eol=lf +*.yaml text eol=lf +*.json text eol=lf +*.md text eol=lf +*.txt text eol=lf +*.html text eol=lf +*.css text eol=lf +*.js text eol=lf +*.gitignore text eol=lf +*.dockerignore text eol=lf +Dockerfile text eol=lf diff --git a/Dockerfile b/Dockerfile index 51cfbf1..5d257cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,3 @@ -# syntax=docker/dockerfile:1 - FROM python:3.11-slim-bookworm # Установка системных зависимостей @@ -7,6 +5,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ build-essential \ libsndfile1 \ + curl \ && rm -rf /var/lib/apt/lists/* # Рабочая директория @@ -14,30 +13,16 @@ WORKDIR /app # Копируем зависимости COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir --timeout 300 -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt # Копируем код проекта COPY . . -# Предзагрузка моделей (HF_TOKEN передаётся через build args) -ARG HF_TOKEN -ENV HF_TOKEN=$HF_TOKEN -RUN if [ -n "$HF_TOKEN" ]; then \ - echo "[Build] Загрузка моделей с HF_TOKEN..."; \ - python scripts/download_models.py; \ - else \ - echo "[Build] HF_TOKEN не передан — модели загрузятся при первом запуске"; \ - fi - # Создаём директории для данных RUN mkdir -p uploads processed tmp # Открываем порт EXPOSE 8000 -# Entrypoint скрипт -COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh -RUN chmod +x /docker-entrypoint.sh - -ENTRYPOINT ["/docker-entrypoint.sh"] +# Запускаем напрямую (модели скачаются при первом запуске, не при сборке!) CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/docker-compose.yml b/docker-compose.yml index f826a37..eccf08b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,6 @@ -version: "3.8" - services: transcription: - build: - context: . - args: - - HF_TOKEN + image: transcription-transcription:latest container_name: transcription_service ports: - "8000:8000" @@ -13,11 +8,14 @@ services: - .env environment: - PYTHONUNBUFFERED=1 + - HF_TOKEN=${HF_TOKEN} volumes: - uploads:/app/uploads - processed:/app/processed - tmp:/app/tmp restart: unless-stopped + entrypoint: ["uvicorn"] + command: ["backend.main:app", "--host", "0.0.0.0", "--port", "8000"] healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/api/files"] interval: 30s