SalesDocSpace / Dockerfile
devcool20's picture
Update Dockerfile
d29d40b verified
# Use an official Python 3.11 slim image with Debian Bookworm (newer)
FROM python:3.11-slim-bookworm
# Set working directory in the container
WORKDIR /app
# Install system dependencies required by deepmost (and generally good for ML)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
git-lfs \
ffmpeg \
libsm6 \
libxext6 \
cmake \
rsync \
libgl1-mesa-glx \
build-essential \
&& rm -rf /var/lib/apt/lists/* \
&& git lfs install
# --- CRITICAL FIX 1: Create /.deepmost and set permissions ---
# Docker images usually run as root during RUN steps.
# Create the directory where deepmost wants to save its files.
RUN mkdir -p /.deepmost && \
chmod 777 /.deepmost # Give read/write/execute permissions to all for this specific folder
# --- CRITICAL FIX 2: Set Hugging Face cache directory to /tmp ---
ENV HF_HOME="/tmp/.hf_cache"
# Also set MPLCONFIGDIR for Matplotlib cache
ENV MPLCONFIGDIR=/tmp/.matplotlib
# Copy requirements.txt and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of your application code
COPY . .
# Set the PORT environment variable. Hugging Face Spaces will
# inject its own PORT value (e.g., 7860), which will override this
# if it's set. This ensures the CMD always has a value.
ENV PORT=7860
# Expose the port Flask will run on
EXPOSE ${PORT}
# Use the shell form of CMD to allow $PORT expansion
# This command will start Gunicorn and bind it to the exposed port.
CMD gunicorn --bind 0.0.0.0:${PORT} app:app --timeout 300 --workers 1