Yeetek's picture
Upload 17 files
b3e0a65 verified
# Dockerfile for Anthropic Topic Segmentation Microservice
# Optimized for HuggingFace Spaces deployment
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
DEBIAN_FRONTEND=noninteractive
# Set working directory
WORKDIR /app
# Install system dependencies (minimal + build tools for psutil)
RUN apt-get update && apt-get install -y \
--no-install-recommends \
curl \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Make startup script executable
RUN chmod +x start.sh
# Create non-root user for security
RUN useradd --create-home --shell /bin/bash app \
&& chown -R app:app /app
USER app
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=15s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
# Expose port (HuggingFace Spaces uses 7860)
EXPOSE 7860
# Start command optimized for HuggingFace Spaces
CMD ["./start.sh"]