misukisu commited on
Commit
f27ffe1
·
verified ·
1 Parent(s): da19cc9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -8
Dockerfile CHANGED
@@ -4,33 +4,33 @@ ENV DEBIAN_FRONTEND=noninteractive \
4
  PYTHONUNBUFFERED=1 \
5
  PORT=7860 \
6
  HOME=/home/user \
7
- PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright
 
8
 
9
- # 1. Install OS libraries for Chromium
10
  RUN apt-get update && apt-get install -y --no-install-recommends \
11
- wget curl gnupg ca-certificates libglib2.0-0 libnss3 libnspr4 \
12
  libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libxcb1 \
13
  libxkbcommon0 libx11-6 libxcomposite1 libxdamage1 libxext6 libxfixes3 \
14
  libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 \
15
  fonts-liberation fonts-noto-color-emoji \
16
  && rm -rf /var/lib/apt/lists/*
17
 
18
- # 2. Setup user and working directories
19
  RUN useradd -m -u 1000 user && \
20
  mkdir -p /home/user/app /home/user/.cache/ms-playwright && \
21
  chown -R user:user /home/user
22
 
23
  WORKDIR /home/user/app
24
 
25
- # 3. Install Python dependencies
26
  COPY --chown=user:user requirements.txt .
27
  RUN pip install --no-cache-dir -r requirements.txt
28
 
29
- # 4. Switch to UID 1000 before installing browser binaries
30
  USER user
31
- RUN patchright install chromium
32
 
33
- # 5. Copy app code
34
  COPY --chown=user:user . .
35
 
36
  EXPOSE 7860
 
4
  PYTHONUNBUFFERED=1 \
5
  PORT=7860 \
6
  HOME=/home/user \
7
+ PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright \
8
+ PATH="/home/user/.local/bin:${PATH}"
9
 
10
+ # Install Chromium system dependencies
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ wget curl ca-certificates libglib2.0-0 libnss3 libnspr4 \
13
  libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libxcb1 \
14
  libxkbcommon0 libx11-6 libxcomposite1 libxdamage1 libxext6 libxfixes3 \
15
  libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 \
16
  fonts-liberation fonts-noto-color-emoji \
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
+ # Create Hugging Face user (UID 1000)
20
  RUN useradd -m -u 1000 user && \
21
  mkdir -p /home/user/app /home/user/.cache/ms-playwright && \
22
  chown -R user:user /home/user
23
 
24
  WORKDIR /home/user/app
25
 
26
+ # Install Python packages
27
  COPY --chown=user:user requirements.txt .
28
  RUN pip install --no-cache-dir -r requirements.txt
29
 
30
+ # Switch to user and download browser
31
  USER user
32
+ RUN python -m patchright install chromium
33
 
 
34
  COPY --chown=user:user . .
35
 
36
  EXPOSE 7860