- Track scanned FTP directories in MongoDB to avoid redundant scans - Add endpoints to view and clear scan cache - Improve health check logic for better startup and error reporting - Add readiness endpoint for deployment probes - Add test script for health check improvements - Increase logging verbosity for debugging
44 lines
1.0 KiB
Docker
44 lines
1.0 KiB
Docker
FROM python:3.9-slim
|
|
|
|
# Set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Set work directory
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
curl \
|
|
libssl-dev \
|
|
libffi-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements and install Python dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY src/ ./src/
|
|
|
|
# Create non-root user for security
|
|
RUN adduser --disabled-password --gecos '' appuser
|
|
RUN chown -R appuser:appuser /app
|
|
USER appuser
|
|
|
|
# Add src directory to PYTHONPATH
|
|
ENV PYTHONPATH="/app/src:$PYTHONPATH"
|
|
|
|
# Expose port
|
|
EXPOSE 8008
|
|
|
|
# Health check - allow more time for service initialization
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=5 \
|
|
CMD curl -f http://localhost:8008/health || exit 1
|
|
|
|
# Start the application from src directory
|
|
WORKDIR /app/src
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8008"]
|