- Use stdlib urllib.request instead of requests library - requests was not installed in the router image, causing healthcheck to always fail with "ModuleNotFoundError: No module named 'requests'" - Increase start_period to 30s and retries to 5 for stability Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
513 B
Docker
37 lines
513 B
Docker
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application
|
|
COPY . .
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Health check (using urllib - no external deps)
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=5 \
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
|
|
|
|
# Run application
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|