|
|
|
FROM python:3.9-slim |
|
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE 1 |
|
ENV PYTHONUNBUFFERED 1 |
|
|
|
|
|
ENV TRANSFORMERS_CACHE=/tmp/huggingface |
|
ENV HF_HOME=/tmp/huggingface |
|
|
|
|
|
RUN mkdir -p /tmp/huggingface && chmod -R 777 /tmp/huggingface |
|
|
|
|
|
RUN mkdir -p /app/.cache/huggingface /app/.cache/matplotlib |
|
|
|
|
|
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface |
|
ENV HF_HOME=/app/.cache/huggingface |
|
ENV MPLCONFIGDIR=/app/.cache/matplotlib |
|
|
|
|
|
RUN chmod -R 777 /app/.cache |
|
|
|
|
|
RUN chmod -R 777 /app |
|
|
|
|
|
RUN mkdir -p /app/logs && chmod -R 777 /app/logs |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
libgl1-mesa-glx \ |
|
libgomp1 \ |
|
libglib2.0-0 \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
ENV MPLCONFIGDIR=/tmp/matplotlib |
|
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache |
|
|
|
|
|
COPY requirements.txt /app/ |
|
|
|
|
|
RUN pip install --no-cache-dir --upgrade -r requirements.txt |
|
|
|
|
|
RUN mkdir -p /app/flask_sessions /app/uploads /tmp/matplotlib /tmp/transformers_cache && chmod -R 777 /app/flask_sessions /app/uploads /tmp/matplotlib /tmp/transformers_cache |
|
|
|
|
|
ENV PADDLEOCR_MODEL_DIR=/tmp/.paddleocr |
|
RUN mkdir -p /tmp/.paddleocr && chmod -R 777 /tmp/.paddleocr |
|
|
|
|
|
|
|
COPY . /app/ |
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
ENV FLASK_APP=app.py |
|
ENV FLASK_ENV=production |
|
|
|
|
|
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"] |
|
|