Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +16 -9
Dockerfile
CHANGED
|
@@ -4,31 +4,38 @@ FROM python:3.9-slim
|
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Install system dependencies
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
wget \
|
| 10 |
gnupg \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
-
#
|
| 14 |
COPY requirements.txt .
|
| 15 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
RUN playwright install-deps chromium
|
|
|
|
| 20 |
|
| 21 |
-
# Copy
|
| 22 |
COPY . .
|
| 23 |
|
| 24 |
-
# Create
|
| 25 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
USER user
|
| 27 |
ENV HOME=/home/user \
|
| 28 |
PATH=/home/user/.local/bin:$PATH
|
| 29 |
|
| 30 |
-
#
|
| 31 |
EXPOSE 7860
|
| 32 |
-
|
| 33 |
-
# Run the application
|
| 34 |
CMD ["python", "app.py"]
|
|
|
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# 1. Install system dependencies
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
wget \
|
| 10 |
gnupg \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# 2. Install Python dependencies
|
| 14 |
COPY requirements.txt .
|
| 15 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
|
| 17 |
+
# 3. CONFIGURE PLAYWRIGHT (The Critical Fix)
|
| 18 |
+
# Set a global path for browsers so both Root (builder) and User (runner) can find them
|
| 19 |
+
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
| 20 |
+
RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH
|
| 21 |
+
|
| 22 |
+
# Install the necessary system dependencies and the Chromium browser
|
| 23 |
RUN playwright install-deps chromium
|
| 24 |
+
RUN playwright install chromium
|
| 25 |
|
| 26 |
+
# 4. Copy Application Code
|
| 27 |
COPY . .
|
| 28 |
|
| 29 |
+
# 5. Create and Switch to Non-Root User
|
| 30 |
RUN useradd -m -u 1000 user
|
| 31 |
+
|
| 32 |
+
# Ensure the user has permissions to access the browsers
|
| 33 |
+
RUN chmod -R 755 $PLAYWRIGHT_BROWSERS_PATH
|
| 34 |
+
|
| 35 |
USER user
|
| 36 |
ENV HOME=/home/user \
|
| 37 |
PATH=/home/user/.local/bin:$PATH
|
| 38 |
|
| 39 |
+
# 6. Run the App
|
| 40 |
EXPOSE 7860
|
|
|
|
|
|
|
| 41 |
CMD ["python", "app.py"]
|