modelLoanStatusCode / Dockerfile
agentsay's picture
Update Dockerfile
422337f verified
FROM python:3.9-slim
# Install system dependencies required for matplotlib and other libraries
RUN apt-get update && apt-get install -y \
gcc \
python3-dev \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 appuser
# Set working directory
WORKDIR /app
# Copy application files
COPY modelLoanAPI.py /app/modelLoanAPI.py
COPY requirements.txt /app/requirements.txt
COPY extended_worker_dataset.csv /app/extended_worker_dataset.csv
COPY extended_worker_dataset_random_reduced.csv /app/extended_worker_dataset_random_reduced.csv
# Set permissions for copied files
RUN chown -R appuser:appuser /app && chmod -R 755 /app
# Create a plots directory with write permissions
RUN mkdir -p /app/plots && chown appuser:appuser /app/plots && chmod -R 775 /app/plots
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Switch to non-root user
USER appuser
# Expose the port
EXPOSE 7860
# Command to run the FastAPI application
CMD ["uvicorn", "modelLoanAPI:app", "--host", "0.0.0.0", "--port", "7860"]