vipsphi commited on
Commit
07dc960
·
verified ·
1 Parent(s): 63cd7b4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -27
Dockerfile CHANGED
@@ -1,39 +1,20 @@
1
  FROM node:20-bullseye-slim
2
 
3
- # Cài đặt các thư viện cần thiết (loại bỏ dbus-x11 nếu không cần thiết, hoặc giữ lại để lấy dbus-launch)
4
  RUN apt-get update && apt-get install -y \
5
- xvfb \
6
- libnss3 \
7
- libatk1.0-0 \
8
- libatk-bridge2.0-0 \
9
- libcups2 \
10
- libdrm2 \
11
- libgtk-3-0 \
12
- libgbm1 \
13
- libasound2 \
14
- libxshmfence1 \
15
- libx11-xcb1 \
16
- dbus-x11 \
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
  WORKDIR /app
20
-
21
- COPY package*.json ./
22
- RUN npm install --unsafe-perm
23
-
24
  COPY . .
 
25
 
26
- # Thiết lập các biến môi trường quan trọng
27
  ENV DISPLAY=:99
28
- ENV ELECTRON_DISABLE_GPU=1
29
- ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
30
-
31
- # Tạo thư mục tạm cho Electron để tránh lỗi quyền ghi
32
  ENV XDG_RUNTIME_DIR=/tmp/runtime-root
33
  RUN mkdir -p /tmp/runtime-root && chmod 0700 /tmp/runtime-root
34
 
35
- # Lệnh CMD mới:
36
- # 1. Khởi chạy Xvfb
37
- # 2. Sử dụng dbus-run-session để bao bọc lệnh npm start (giúp giải quyết lỗi Bus mà không cần quyền root)
38
- CMD Xvfb :99 -screen 0 1280x1024x24 & \
39
- dbus-run-session -- npm start -- --no-sandbox --disable-gpu --disable-dev-shm-usage
 
1
  FROM node:20-bullseye-slim
2
 
3
+ # Cài đặt đầy đủ dependency cho Electron
4
  RUN apt-get update && apt-get install -y \
5
+ xvfb libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
6
+ libgtk-3-0 libgbm1 libasound2 libxshmfence1 libx11-xcb1 dbus-x11 \
 
 
 
 
 
 
 
 
 
 
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
  WORKDIR /app
 
 
 
 
10
  COPY . .
11
+ RUN npm install --unsafe-perm
12
 
13
+ # Thiết lập màn hình ảo
14
  ENV DISPLAY=:99
 
 
 
 
15
  ENV XDG_RUNTIME_DIR=/tmp/runtime-root
16
  RUN mkdir -p /tmp/runtime-root && chmod 0700 /tmp/runtime-root
17
 
18
+ # Chạy với dbus-run-session để ổn định tiến trình
19
+ CMD Xvfb :99 -screen 0 1280x720x24 & \
20
+ dbus-run-session -- npm start -- --no-sandbox --disable-gpu