likhonsheikh commited on
Commit
31e4e60
·
verified ·
1 Parent(s): 47d9c07

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -20
Dockerfile CHANGED
@@ -1,24 +1,44 @@
1
- # Dockerfile for lightweight Playwright + FastAPI app on Hugging Face Space
2
 
3
- FROM python:3.11-slim
 
4
 
5
  # Install dependencies
6
  RUN apt-get update && apt-get install -y \
7
- libnss3 libatk-bridge2.0-0 libgtk-3-0 libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libasound2 curl \
8
- && rm -rf /var/lib/apt/lists/*
9
-
10
- # Install Playwright and FastAPI dependencies
11
- RUN pip install --no-cache-dir fastapi uvicorn "playwright>=1.37.0" httpx
12
-
13
- # Install Playwright browsers
14
- RUN playwright install
15
-
16
- WORKDIR /app
17
-
18
- COPY ./app /app
19
-
20
- ENV PORT=7860
21
- EXPOSE 7860
22
-
23
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
24
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ubuntu:22.04
2
 
3
+ # Set non-interactive frontend
4
+ ENV DEBIAN_FRONTEND=noninteractive
5
 
6
  # Install dependencies
7
  RUN apt-get update && apt-get install -y \
8
+ python3-pip \
9
+ python3-venv \
10
+ git \
11
+ curl \
12
+ wget \
13
+ vim \
14
+ --no-install-recommends \
15
+ && apt-get clean \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Install Playwright and its dependencies
19
+ RUN pip3 install --no-cache-dir playwright pytest pytest-playwright
20
+ RUN playwright install --with-deps chromium firefox webkit
21
+
22
+ # Set up a non-root user with sudo privileges
23
+ RUN useradd -ms /bin/bash gemini \
24
+ && apt-get update \
25
+ && apt-get install -y sudo \
26
+ && echo "gemini ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/gemini
27
+
28
+ # Create and set permissions for workspace
29
+ RUN mkdir -p /home/gemini/workspace \
30
+ && chown -R gemini:gemini /home/gemini
31
+
32
+ USER gemini
33
+ WORKDIR /home/gemini/workspace
34
+
35
+ # Set environment variables
36
+ ENV PATH="/home/gemini/.local/bin:${PATH}"
37
+ ENV PYTHONPATH="/home/gemini/workspace:${PYTHONPATH}"
38
+
39
+ # Expose ports for the tool API server and debugging
40
+ EXPOSE 8001 9229
41
+
42
+ # Add healthcheck
43
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
44
+ CMD curl -f http://localhost:8001/ || exit 1