File size: 940 Bytes
68b95db ef5ef96 a156160 ef5ef96 a156160 977b1c3 a156160 ef5ef96 68b95db a156160 ef5ef96 a156160 ef5ef96 a156160 977b1c3 015d69d a156160 977b1c3 68b95db a156160 977b1c3 ef5ef96 68b95db 015d69d 68b95db |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
FROM python:3.9-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Create directories with secure permissions
RUN mkdir -p cache/huggingface vector_store chat_history \
&& chown -R 1000:1000 . \
&& chmod -R 755 .
# Copy dependencies separately for caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy source code
COPY . .
# Set environment variables
ENV HF_HOME=/app/cache/huggingface
ENV HUGGINGFACE_HUB_CACHE=/app/cache/huggingface
ENV XDG_CACHE_HOME=/app/cache
# Set permissions (only for newly created files)
RUN chown -R 1000:1000 /app \
&& find /app -type d -exec chmod 755 {} \; \
&& find /app -type f -exec chmod 644 {} \;
# Run as non-privileged user
USER 1000
EXPOSE 8000
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] |