FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ git \ postgresql-client \ curl \ build-essential \ && 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 the service code COPY . . # Create necessary directories RUN mkdir -p /app/logs /app/temp /app/reports # Set environment variables ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 ENV PORT=8022 # Expose port EXPOSE 8022 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:8022/health || exit 1 # Run migration and then start the service CMD ["sh", "-c", "python run_migration.py && python server.py"]