DocTranslator / Dockerfile
yasmine110's picture
Update Dockerfile
793292b verified
FROM python:3.9-slim as builder
WORKDIR /app
# 1. Installer les dépendances système
RUN apt-get update && apt-get install -y \
libmagic1 \
poppler-utils \
&& rm -rf /var/lib/apt/lists/*
# 2. Configurer le cache
RUN mkdir -p /cache/huggingface && chmod 777 /cache
# 3. Installer les dépendances Python
COPY ./backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ----------------------------------------
FROM python:3.9-slim
WORKDIR /app
# 4. Copier depuis le builder
COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
COPY --from=builder /usr/local/bin/uvicorn /usr/local/bin/
COPY --from=builder /cache /cache
# 5. Copier l'application
COPY ./frontend /app/frontend
COPY ./backend /app/backend
COPY Dockerfile README.md ./
# 6. Configurer l'environnement
ENV TRANSFORMERS_CACHE=/cache/huggingface
ENV HF_HOME=/cache/huggingface
ENV PYTHONPATH=/app
# 7. Permissions
RUN chmod +x /usr/local/bin/uvicorn && \
chmod -R a+rwx /app && \
chmod -R a+rwx /cache
# 8. Port et commande
EXPOSE 7860
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]