sylvain471 commited on
Commit
e092640
·
verified ·
1 Parent(s): 737d589

Upload 5 files

Browse files
Files changed (3) hide show
  1. Dockerfile +28 -8
  2. app.py +1 -0
  3. requirements.txt +2 -1
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM python:3.11
2
 
3
  RUN apt-get update && apt-get install -y \
4
  libnss3 \
@@ -14,18 +14,38 @@ RUN apt-get update && apt-get install -y \
14
  libgtk-3-0 \
15
  xdg-utils \
16
  libasound2 \
 
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
- # Install Playwright and other dependencies
20
- RUN pip install --upgrade pip
21
- COPY requirements.txt .
22
- RUN pip install -r requirements.txt
23
- RUN playwright install-deps
 
 
 
 
24
 
25
  RUN useradd -m -u 1000 user
26
  USER user
27
- WORKDIR /app
28
 
29
- COPY --chown=user:user . /app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  CMD ["python", "app.py"]
 
1
+ FROM python:3.10-slim
2
 
3
  RUN apt-get update && apt-get install -y \
4
  libnss3 \
 
14
  libgtk-3-0 \
15
  xdg-utils \
16
  libasound2 \
17
+ mc \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
+ WORKDIR /code
21
+
22
+ COPY ./requirements.txt /code/requirements.txt
23
+
24
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
25
+
26
+ RUN pip install playwright
27
+ RUN playwright install --with-deps
28
+
29
 
30
  RUN useradd -m -u 1000 user
31
  USER user
 
32
 
33
+ ENV HOME=/home/user \
34
+ PATH=/home/user/.local/bin:$PATH \
35
+ PYTHONPATH=$HOME/app \
36
+ PYTHONUNBUFFERED=1 \
37
+ GRADIO_ALLOW_FLAGGING=never \
38
+ GRADIO_NUM_PORTS=1 \
39
+ GRADIO_SERVER_NAME=0.0.0.0 \
40
+ GRADIO_THEME=huggingface \
41
+ SYSTEM=spaces
42
+
43
+ # Set the working directory to the user's home directory
44
+ WORKDIR $HOME/app
45
+
46
+ RUN playwright install firefox
47
+
48
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
49
+ COPY --chown=user . $HOME/app
50
 
51
  CMD ["python", "app.py"]
app.py CHANGED
@@ -5,6 +5,7 @@ import os
5
  from dotenv import load_dotenv
6
 
7
  if os.getenv('ENVIRONMENT')=="PROD":
 
8
  subprocess.run(["playwright","install","firefox"])
9
 
10
  def fetch_homework(date:str='today') -> str:
 
5
  from dotenv import load_dotenv
6
 
7
  if os.getenv('ENVIRONMENT')=="PROD":
8
+ print("installing playwright firefox")
9
  subprocess.run(["playwright","install","firefox"])
10
 
11
  def fetch_homework(date:str='today') -> str:
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  gradio[mcp]
2
  python-dotenv
3
- playwright
 
 
1
  gradio[mcp]
2
  python-dotenv
3
+ # pytest-playwright
4
+ # playwright