Fix Docker: correct entrypoint, remove hf_cache volume overlap, use existing image with models
This commit is contained in:
parent
714ac06364
commit
ea1904f9af
@ -37,6 +37,7 @@ video/
|
|||||||
*.docx
|
*.docx
|
||||||
*.md
|
*.md
|
||||||
*.txt
|
*.txt
|
||||||
|
!requirements.txt
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|||||||
14
.gitattributes
vendored
Normal file
14
.gitattributes
vendored
Normal file
@ -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
|
||||||
21
Dockerfile
21
Dockerfile
@ -1,5 +1,3 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
|
|
||||||
FROM python:3.11-slim-bookworm
|
FROM python:3.11-slim-bookworm
|
||||||
|
|
||||||
# Установка системных зависимостей
|
# Установка системных зависимостей
|
||||||
@ -7,6 +5,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
ffmpeg \
|
ffmpeg \
|
||||||
build-essential \
|
build-essential \
|
||||||
libsndfile1 \
|
libsndfile1 \
|
||||||
|
curl \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Рабочая директория
|
# Рабочая директория
|
||||||
@ -14,30 +13,16 @@ WORKDIR /app
|
|||||||
|
|
||||||
# Копируем зависимости
|
# Копируем зависимости
|
||||||
COPY requirements.txt .
|
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 . .
|
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
|
RUN mkdir -p uploads processed tmp
|
||||||
|
|
||||||
# Открываем порт
|
# Открываем порт
|
||||||
EXPOSE 8000
|
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"]
|
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
|
|||||||
@ -1,11 +1,6 @@
|
|||||||
version: "3.8"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
transcription:
|
transcription:
|
||||||
build:
|
image: transcription-transcription:latest
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
- HF_TOKEN
|
|
||||||
container_name: transcription_service
|
container_name: transcription_service
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
@ -13,11 +8,14 @@ services:
|
|||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
- PYTHONUNBUFFERED=1
|
- PYTHONUNBUFFERED=1
|
||||||
|
- HF_TOKEN=${HF_TOKEN}
|
||||||
volumes:
|
volumes:
|
||||||
- uploads:/app/uploads
|
- uploads:/app/uploads
|
||||||
- processed:/app/processed
|
- processed:/app/processed
|
||||||
- tmp:/app/tmp
|
- tmp:/app/tmp
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
entrypoint: ["uvicorn"]
|
||||||
|
command: ["backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:8000/api/files"]
|
test: ["CMD", "curl", "-f", "http://localhost:8000/api/files"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user