Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +13 -7
Dockerfile
CHANGED
|
@@ -3,9 +3,10 @@ FROM python:3.11-slim
|
|
| 3 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 4 |
PYTHONUNBUFFERED=1 \
|
| 5 |
PORT=7860 \
|
| 6 |
-
HOME=/home/user
|
|
|
|
| 7 |
|
| 8 |
-
# Install OS libraries
|
| 9 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
wget curl gnupg ca-certificates libglib2.0-0 libnss3 libnspr4 \
|
| 11 |
libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libxcb1 \
|
|
@@ -14,19 +15,24 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 14 |
fonts-liberation fonts-noto-color-emoji \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
|
|
|
| 19 |
WORKDIR /home/user/app
|
| 20 |
|
|
|
|
| 21 |
COPY --chown=user:user requirements.txt .
|
| 22 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
|
|
|
| 26 |
|
|
|
|
| 27 |
COPY --chown=user:user . .
|
| 28 |
|
| 29 |
-
USER user
|
| 30 |
EXPOSE 7860
|
| 31 |
|
| 32 |
CMD ["python", "app.py"]
|
|
|
|
| 3 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 4 |
PYTHONUNBUFFERED=1 \
|
| 5 |
PORT=7860 \
|
| 6 |
+
HOME=/home/user \
|
| 7 |
+
PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright
|
| 8 |
|
| 9 |
+
# 1. Install OS libraries for Chromium
|
| 10 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 11 |
wget curl gnupg ca-certificates libglib2.0-0 libnss3 libnspr4 \
|
| 12 |
libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libxcb1 \
|
|
|
|
| 15 |
fonts-liberation fonts-noto-color-emoji \
|
| 16 |
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
|
| 18 |
+
# 2. Setup user and working directories
|
| 19 |
+
RUN useradd -m -u 1000 user && \
|
| 20 |
+
mkdir -p /home/user/app /home/user/.cache/ms-playwright && \
|
| 21 |
+
chown -R user:user /home/user
|
| 22 |
+
|
| 23 |
WORKDIR /home/user/app
|
| 24 |
|
| 25 |
+
# 3. Install Python dependencies
|
| 26 |
COPY --chown=user:user requirements.txt .
|
| 27 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
+
# 4. Switch to UID 1000 before installing browser binaries
|
| 30 |
+
USER user
|
| 31 |
+
RUN patchright install chromium
|
| 32 |
|
| 33 |
+
# 5. Copy app code
|
| 34 |
COPY --chown=user:user . .
|
| 35 |
|
|
|
|
| 36 |
EXPOSE 7860
|
| 37 |
|
| 38 |
CMD ["python", "app.py"]
|