Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +23 -15
Dockerfile
CHANGED
|
@@ -1,31 +1,39 @@
|
|
| 1 |
-
|
| 2 |
FROM python:3.9-slim
|
| 3 |
-
USER root
|
| 4 |
|
| 5 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
-
# Copy
|
| 9 |
COPY modelLoanAPI.py /app/modelLoanAPI.py
|
| 10 |
-
|
| 11 |
-
# Copy requirements file (created below)
|
| 12 |
COPY requirements.txt /app/requirements.txt
|
| 13 |
-
|
| 14 |
COPY extended_worker_dataset.csv /app/extended_worker_dataset.csv
|
| 15 |
COPY extended_worker_dataset_random_reduced.csv /app/extended_worker_dataset_random_reduced.csv
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
RUN
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 23 |
|
| 24 |
# Install Python dependencies
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
-
#
|
|
|
|
|
|
|
|
|
|
| 28 |
EXPOSE 7860
|
| 29 |
|
| 30 |
# Command to run the FastAPI application
|
| 31 |
-
CMD ["uvicorn", "modelLoanAPI:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
|
| 2 |
FROM python:3.9-slim
|
|
|
|
| 3 |
|
| 4 |
+
# Install system dependencies required for matplotlib and other libraries
|
| 5 |
+
RUN apt-get update && apt-get install -y \
|
| 6 |
+
gcc \
|
| 7 |
+
python3-dev \
|
| 8 |
+
libpq-dev \
|
| 9 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
+
|
| 11 |
+
# Create a non-root user
|
| 12 |
+
RUN useradd -m -u 1000 appuser
|
| 13 |
+
|
| 14 |
+
# Set working directory
|
| 15 |
WORKDIR /app
|
| 16 |
|
| 17 |
+
# Copy application files
|
| 18 |
COPY modelLoanAPI.py /app/modelLoanAPI.py
|
|
|
|
|
|
|
| 19 |
COPY requirements.txt /app/requirements.txt
|
|
|
|
| 20 |
COPY extended_worker_dataset.csv /app/extended_worker_dataset.csv
|
| 21 |
COPY extended_worker_dataset_random_reduced.csv /app/extended_worker_dataset_random_reduced.csv
|
| 22 |
|
| 23 |
+
# Set permissions for copied files
|
| 24 |
+
RUN chown -R appuser:appuser /app && chmod -R 755 /app
|
| 25 |
+
|
| 26 |
+
# Create a plots directory with write permissions
|
| 27 |
+
RUN mkdir -p /app/plots && chown appuser:appuser /app/plots && chmod -R 775 /app/plots
|
|
|
|
| 28 |
|
| 29 |
# Install Python dependencies
|
| 30 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 31 |
|
| 32 |
+
# Switch to non-root user
|
| 33 |
+
USER appuser
|
| 34 |
+
|
| 35 |
+
# Expose the port
|
| 36 |
EXPOSE 7860
|
| 37 |
|
| 38 |
# Command to run the FastAPI application
|
| 39 |
+
CMD ["uvicorn", "modelLoanAPI:app", "--host", "0.0.0.0", "--port", "7860"]
|