abcd118q commited on
Commit
9acbf1a
·
verified ·
1 Parent(s): b7de548

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -0
Dockerfile ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a lightweight Python 3.10 base image
2
+ FROM python:3.10-slim
3
+
4
+ # 1. Install Python dependencies
5
+ RUN pip install --no-cache-dir fastapi uvicorn websockets playwright
6
+
7
+ # 2. Install system dependencies required by Chromium
8
+ RUN playwright install-deps chromium
9
+
10
+ # 3. Create a non-root user (UID 1000) as required by Hugging Face Spaces
11
+ RUN useradd -m -u 1000 user
12
+
13
+ # 4. Create the /app directory and set ownership BEFORE switching users
14
+ RUN mkdir -p /app/static && chown -R user:user /app
15
+
16
+ # 5. Switch to the non-root user
17
+ USER user
18
+
19
+ # 6. Install Chromium as the non-root user (installs to their ~/.cache)
20
+ RUN playwright install chromium
21
+
22
+ # 7. Set working directory
23
+ WORKDIR /app
24
+
25
+ # 8. Copy application files with proper user ownership
26
+ COPY --chown=user:user browser_server.py /app/
27
+ COPY --chown=user:user static/browser.html /app/static/
28
+
29
+ # 9. Expose the Hugging Face Spaces default port
30
+ EXPOSE 7860
31
+
32
+ # 10. Start the server using Uvicorn directly
33
+ # This binds it to HF's required port 7860.
34
+ CMD ["uvicorn", "browser_server:app", "--host", "0.0.0.0", "--port", "7860"]