Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +28 -10
Dockerfile
CHANGED
|
@@ -1,15 +1,33 @@
|
|
| 1 |
-
# Use a
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
-
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a stable Python base image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
# Set environment variables to prevent interactive prompts during installation
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
|
| 7 |
+
# Install necessary system dependencies, including Chromium and Xvfb
|
| 8 |
+
RUN apt-get update && \
|
| 9 |
+
apt-get install -y --no-install-recommends \
|
| 10 |
+
chromium \
|
| 11 |
+
chromium-driver \
|
| 12 |
+
xvfb \
|
| 13 |
+
&& \
|
| 14 |
+
apt-get clean && \
|
| 15 |
+
rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
+
# Create a non-root user for security
|
| 18 |
+
RUN useradd -m appuser
|
| 19 |
+
USER appuser
|
| 20 |
+
WORKDIR /home/appuser/app
|
| 21 |
|
| 22 |
+
# Copy the requirements file and install Python packages
|
| 23 |
+
COPY --chown=appuser:appuser requirements.txt .
|
| 24 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 25 |
+
|
| 26 |
+
# Copy the application code
|
| 27 |
+
COPY --chown=appuser:appuser main.py .
|
| 28 |
+
|
| 29 |
+
# Expose the port the API will run on
|
| 30 |
+
EXPOSE 7860
|
| 31 |
+
|
| 32 |
+
# The command to run the FastAPI application
|
| 33 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|