Spaces:
Sleeping
Sleeping
File size: 1,088 Bytes
cf02b2b 547fc39 e8acb05 cf02b2b 547fc39 cf02b2b 547fc39 |
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 40 41 42 43 |
# Use Python 3.12 as specified
FROM python:3.12-slim
# Install minimal system dependencies including git-lfs for database files
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Set working directory
WORKDIR /app
# Copy requirements first for better Docker layer caching
COPY --chown=user ./requirements.txt requirements.txt
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the application code
COPY --chown=user . /app
# Make startup script executable
RUN chmod +x startup.sh
# Expose the port that HF Spaces requires
EXPOSE 7860
# Set environment variables
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Run the application with LFS data download
CMD ["./startup.sh"]
|