mrfirdauss commited on
Commit
f0ea208
·
1 Parent(s): bbe93df

fix: playwright cache

Browse files
Files changed (2) hide show
  1. Dockerfile +6 -3
  2. server.py +2 -0
Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
  # Base image
2
- FROM python:latest AS base
3
 
4
- WORKDIR /app
5
 
6
  COPY requirements.txt .
7
 
@@ -10,12 +10,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
10
  pip install --upgrade pip && \
11
  pip install --no-cache-dir -r requirements.txt && \
12
  pip install playwright && \
13
- playwright install --with-deps && \
 
14
  apt-get clean && rm -rf /var/lib/apt/lists/*
15
 
16
  COPY . .
 
17
 
18
  EXPOSE 7860
19
  ENV PORT=7860
 
20
 
21
  CMD ["python", "-m", "hypercorn", "server:app", "-b", "0.0.0.0:7860", "--access-log", "-", "--error-log", "-"]
 
1
  # Base image
2
+ FROM python:3.13-slim AS base
3
 
4
+ WORKDIR /home/user/app
5
 
6
  COPY requirements.txt .
7
 
 
10
  pip install --upgrade pip && \
11
  pip install --no-cache-dir -r requirements.txt && \
12
  pip install playwright && \
13
+ mkdir -p /home/user/.cache/ms-playwright && \
14
+ PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright playwright install --with-deps && \
15
  apt-get clean && rm -rf /var/lib/apt/lists/*
16
 
17
  COPY . .
18
+ RUN chmod -R 755 /home/user
19
 
20
  EXPOSE 7860
21
  ENV PORT=7860
22
+ ENV PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright
23
 
24
  CMD ["python", "-m", "hypercorn", "server:app", "-b", "0.0.0.0:7860", "--access-log", "-", "--error-log", "-"]
server.py CHANGED
@@ -1,4 +1,6 @@
1
  import os
 
 
2
  import logging
3
  from flask import Flask, request, jsonify
4
  from dotenv import load_dotenv
 
1
  import os
2
+ os.environ["PLAYWRIGHT_BROWSERS_PATH"] = "/home/user/.cache/ms-playwright"
3
+
4
  import logging
5
  from flask import Flask, request, jsonify
6
  from dotenv import load_dotenv