Tegaconsult's picture
Update Dockerfile
5014168 verified
raw
history blame contribute delete
822 Bytes
FROM python:3.10-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application files
COPY ml.py .
COPY app.py .
# Create a non-root user
RUN useradd -m -u 1000 user
USER user
# Set environment variables
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy files to user directory
COPY --chown=user . $HOME/app
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
CMD ["uvicorn", "ml:app", "--host", "0.0.0.0", "--port", "7860"]