File size: 903 Bytes
d95288a 4b53ea5 d95288a 4b53ea5 d95288a 4b53ea5 d95288a 4b53ea5 d95288a 4b53ea5 9a458e0 d95288a 4b53ea5 |
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 |
FROM python:3.11-slim
# Install build dependencies with optimizations for smaller image
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
WORKDIR /code
# Copy and install requirements with optimizations
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create model directory and set permissions
RUN mkdir -p /code/model && \
chmod -R 777 /code && \
find /code -type f -name "*.py" -exec chmod +x {} \;
# Optimize Python performance
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONOPTIMIZE=1
EXPOSE 7860
# Use optimized uvicorn settings for free tier
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--loop", "asyncio", "--access-log"]
|