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