Spaces:
Running
Running
MaSTer-suFYan commited on
Commit ·
e94e71b
1
Parent(s): a15ff0a
fix: UID 1000 conflict with Microsoft Playwright base image
Browse files- Dockerfile +19 -16
Dockerfile
CHANGED
|
@@ -1,27 +1,30 @@
|
|
| 1 |
# Use an official Python runtime with Playwright dependencies already installed
|
| 2 |
FROM mcr.microsoft.com/playwright/python:v1.43.0-jammy
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
ENV HOME=/home/user \
|
| 8 |
-
PATH=/home/user/.local/bin:$PATH
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
# Copy application files and give ownership to the new user
|
| 14 |
-
COPY --chown=user . $HOME/app/
|
| 15 |
-
|
| 16 |
-
# Install python dependencies
|
| 17 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 18 |
RUN pip install gunicorn
|
| 19 |
|
| 20 |
-
# Ensure playwright browsers are installed
|
| 21 |
RUN playwright install chromium
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Set environment variables for the Hugging Face Space port (7860)
|
| 27 |
ENV PYTHONUNBUFFERED=1
|
|
@@ -31,7 +34,7 @@ ENV PORT=7860
|
|
| 31 |
EXPOSE 7860
|
| 32 |
|
| 33 |
# Switch to the app's python directory
|
| 34 |
-
WORKDIR
|
| 35 |
|
| 36 |
# Start Gunicorn binding to port 7860
|
| 37 |
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--threads", "4", "--worker-class", "gthread", "--timeout", "120", "wsgi:app"]
|
|
|
|
| 1 |
# Use an official Python runtime with Playwright dependencies already installed
|
| 2 |
FROM mcr.microsoft.com/playwright/python:v1.43.0-jammy
|
| 3 |
|
| 4 |
+
# 1. We start as root to install packages and copy files
|
| 5 |
+
USER root
|
| 6 |
+
WORKDIR /app
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
# Copy requirements and install
|
| 9 |
+
COPY requirements.txt .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 11 |
RUN pip install gunicorn
|
| 12 |
|
| 13 |
+
# Ensure playwright browsers are installed
|
| 14 |
RUN playwright install chromium
|
| 15 |
|
| 16 |
+
# Copy all application files
|
| 17 |
+
COPY . .
|
| 18 |
+
|
| 19 |
+
# Ensure output directory exists and is writable
|
| 20 |
+
RUN mkdir -p /app/lead_gen/output && chmod 777 -R /app/lead_gen/output
|
| 21 |
+
|
| 22 |
+
# Give ownership of /app to UID 1000 (The user Hugging Face Forces)
|
| 23 |
+
RUN chown -R 1000:1000 /app
|
| 24 |
+
|
| 25 |
+
# 2. Switch to the non-root user (UID 1000) required by Hugging Face
|
| 26 |
+
# In this Playwright base image, UID 1000 already belongs to 'pwuser', so we don't need useradd.
|
| 27 |
+
USER 1000
|
| 28 |
|
| 29 |
# Set environment variables for the Hugging Face Space port (7860)
|
| 30 |
ENV PYTHONUNBUFFERED=1
|
|
|
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
# Switch to the app's python directory
|
| 37 |
+
WORKDIR /app/lead_gen
|
| 38 |
|
| 39 |
# Start Gunicorn binding to port 7860
|
| 40 |
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--threads", "4", "--worker-class", "gthread", "--timeout", "120", "wsgi:app"]
|