FROM python:3.10-slim ENV DEBIAN_FRONTEND=noninteractive # System packages required for KoNLPy (Java) and MeCab tokenizer RUN apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ default-jdk \ mecab \ libmecab-dev \ mecab-ipadic-utf8 \ python3-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Create non-root user (UID 1000) recommended for Spaces Dev Mode RUN useradd -m -u 1000 user ENV HOME=/home/user \ PATH="/home/user/.local/bin:$PATH" \ HF_HOME=/home/user/.cache/huggingface WORKDIR ${HOME}/app # Install Python dependencies COPY --chown=user:user requirements.txt ./ RUN pip install --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # Copy application source and artifacts with correct ownership COPY --chown=user:user . . USER user ENV PYTHONPATH=${HOME}/app \ PORT=7860 EXPOSE 7860 # Gunicorn respects the PORT provided by Hugging Face Spaces. CMD ["sh", "-c", "gunicorn --bind 0.0.0.0:${PORT:-7860} --workers ${GUNICORN_WORKERS:-2} wsgi:application"]