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
|
||||
*.md
|
||||
*.txt
|
||||
!requirements.txt
|
||||
|
||||
# IDE
|
||||
.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
|
||||
|
||||
# Установка системных зависимостей
|
||||
@ -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"]
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user