Spaces:
Sleeping
Sleeping
Mohammad Zeeshan commited on
Update Dockerfile
Browse files1 unmodified line2345678910111216 unmodified lines29303132333435363738391 unmodified lineFROM python:3.9-slim AS builderWORKDIR /appCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtRUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpuRUN python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"# 🚀 Stage 2: Final optimized production image16 unmodified lines# Copy application codeCOPY . .# Preload the model (avoid startup delays)RUN python -c "from transformers import pipeline; pipeline('translation', model='facebook/m2m100_418M')"# Expose portEXPOSE 7860# Start the FastAPI server using UvicornCMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2", "--timeout-keep-alive", "5"]1 unmodified line2345678910111213141516 unmodified lines32333435363738391 unmodified lineFROM python:3.9-slim AS builderWORKDIR /app# Install dependencies in a single step to optimize layersCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt \&& pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu \&& pip install --no-cache-dir uvicorn[standard] transformers# Verify installationRUN python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"# 🚀 Stage 2: Final optimized production image16 unmodified lines# Copy application codeCOPY . .# Expose portEXPOSE 7860# Start FastAPI with optimized settingsCMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--timeout-keep-alive", "10"]
Dockerfile+8-8