Vo Hoang Minh commited on
Commit
b0561f3
·
1 Parent(s): f735bb4
Files changed (2) hide show
  1. Dockerfile +16 -14
  2. entrypoint.sh +20 -24
Dockerfile CHANGED
@@ -1,11 +1,12 @@
1
  # Sử dụng Debian Slim để giảm kích thước image nhưng vẫn giữ sự tương thích
2
  FROM node:22
3
 
 
4
  RUN corepack enable && \
5
  corepack prepare pnpm@latest --activate && \
6
- apt-get update && apt-get install -y curl && \
7
- curl -fsSL https://bun.sh/install | bash && \
8
- ln -s /root/.bun/bin/bun /usr/local/bin/bun
9
 
10
  # Thiết lập môi trường
11
  ENV DEBIAN_FRONTEND=noninteractive \
@@ -49,13 +50,15 @@ COPY ./ /opt/orbita/
49
  COPY orbita.conf /etc/nginx/conf.d/orbita.conf
50
  RUN rm /etc/nginx/sites-enabled/default
51
 
52
- # Tạo file cấu hình nginx.conf mới với user root
53
  RUN echo 'user root;\nworker_processes auto;\npid /run/nginx.pid;\ninclude /etc/nginx/modules-enabled/*.conf;\n\nevents {\n worker_connections 768;\n}\n\nhttp {\n include /etc/nginx/mime.types;\n include /etc/nginx/conf.d/*.conf;\n default_type application/octet-stream;\n sendfile on;\n tcp_nopush on;\n types_hash_max_size 2048;\n keepalive_timeout 65;\n gzip on;\n access_log /var/log/nginx/access.log;\n error_log /var/log/nginx/error.log;\n}' > /etc/nginx/nginx.conf
54
 
55
- # Cấp quyền truy cập cho nginx các thư mục cần thiết
56
- RUN chmod 777 /var/lib/nginx -R && \
57
- chmod 777 /var/log -R && \
58
- chmod 777 /run -R
 
 
59
 
60
  # Cấu hình X11
61
  RUN mkdir /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix
@@ -64,15 +67,14 @@ RUN mkdir /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix
64
  COPY entrypoint.sh /entrypoint.sh
65
  # COPY fonts /home/orbita/.gologin/browser/fonts
66
 
67
- # Không tạo user orbita, sử dụng root cho tất cả
68
- RUN mkdir -p /root/Downloads /home/orbita/.gologin/browser/fonts && \
69
- chmod -R 777 /home/orbita
70
 
71
  # Cấp quyền cho entrypoint.sh
72
- RUN chmod 777 /entrypoint.sh
73
 
74
- # bun install package.json
75
- RUN bun install
76
 
77
  # Sử dụng user root cho tất cả dịch vụ
78
  USER root
 
1
  # Sử dụng Debian Slim để giảm kích thước image nhưng vẫn giữ sự tương thích
2
  FROM node:22
3
 
4
+ # Đảm bảo cài đặt Node.js và npm trước
5
  RUN corepack enable && \
6
  corepack prepare pnpm@latest --activate && \
7
+ apt-get update && \
8
+ apt-get install -y curl sudo && \
9
+ npm install -g bun
10
 
11
  # Thiết lập môi trường
12
  ENV DEBIAN_FRONTEND=noninteractive \
 
50
  COPY orbita.conf /etc/nginx/conf.d/orbita.conf
51
  RUN rm /etc/nginx/sites-enabled/default
52
 
53
+ # Tạo file cấu hình nginx.conf mới với user root (sử dụng sudo để tránh lỗi quyền)
54
  RUN echo 'user root;\nworker_processes auto;\npid /run/nginx.pid;\ninclude /etc/nginx/modules-enabled/*.conf;\n\nevents {\n worker_connections 768;\n}\n\nhttp {\n include /etc/nginx/mime.types;\n include /etc/nginx/conf.d/*.conf;\n default_type application/octet-stream;\n sendfile on;\n tcp_nopush on;\n types_hash_max_size 2048;\n keepalive_timeout 65;\n gzip on;\n access_log /var/log/nginx/access.log;\n error_log /var/log/nginx/error.log;\n}' > /etc/nginx/nginx.conf
55
 
56
+ # Đảm bảo quyền cho các file Nginx (không sử dụng chmod -R)
57
+ RUN mkdir -p /var/lib/nginx && \
58
+ mkdir -p /var/log/nginx && \
59
+ mkdir -p /var/run/nginx && \
60
+ touch /var/log/nginx/access.log && \
61
+ touch /var/log/nginx/error.log
62
 
63
  # Cấu hình X11
64
  RUN mkdir /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix
 
67
  COPY entrypoint.sh /entrypoint.sh
68
  # COPY fonts /home/orbita/.gologin/browser/fonts
69
 
70
+ # Đảm bảo các thư mục cho orbita quyền truy cập đúng
71
+ RUN mkdir -p /home/orbita/Downloads /home/orbita/.gologin/browser/fonts
 
72
 
73
  # Cấp quyền cho entrypoint.sh
74
+ RUN chmod +x /entrypoint.sh
75
 
76
+ # Cài đặt dependencies từ package.json
77
+ RUN cd /opt/orbita && npm install
78
 
79
  # Sử dụng user root cho tất cả dịch vụ
80
  USER root
entrypoint.sh CHANGED
@@ -1,35 +1,31 @@
1
  #!/bin/bash
2
 
3
- # Đảm bảo thư mục và quyền truy cập cho user root
4
- mkdir -p /root/.vnc
5
- mkdir -p /var/log/nginx
6
- chmod -R 777 /var/log/nginx
7
- chmod -R 777 /var/lib/nginx
8
- chmod -R 777 /run
9
-
10
- # Thiết lập display cho X server
11
- DISPLAY=:0
12
- export DISPLAY=:0
13
- echo $SCREEN_WIDTH
14
- echo $SCREEN_HEIGHT
15
- echo `echo $SCREEN_WIDTH`x`echo $SCREEN_HEIGHT`x16
16
-
17
  # Khởi động Xvfb nền
18
- Xvfb :0 -screen 0 "${SCREEN_WIDTH:-1280}x${SCREEN_HEIGHT:-720}x16" &
19
-
20
- cd /opt/orbita
21
 
22
  # Log thông tin về user hiện tại và quyền
23
  echo "Current user: $(whoami)"
24
- echo "Starting services as root user..."
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- # Khởi động ứng dụng bằng bun
27
- bun run dev &
 
28
 
29
  # Kiểm tra file nginx.conf
30
  echo "Checking nginx configuration..."
31
- cat /etc/nginx/nginx.conf | grep "user"
32
 
33
- # Khởi động nginx với quyền root
34
- echo "Starting Nginx with root user..."
35
- /usr/sbin/nginx -c /etc/nginx/nginx.conf
 
1
  #!/bin/bash
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  # Khởi động Xvfb nền
4
+ # Xvfb :0 -screen 0 "${SCREEN_WIDTH:-1280}x${SCREEN_HEIGHT:-720}x16" &
 
 
5
 
6
  # Log thông tin về user hiện tại và quyền
7
  echo "Current user: $(whoami)"
8
+ echo "Starting services..."
9
+
10
+ cd /opt/orbita
11
+
12
+ # Kiểm tra bun đã được cài đặt đúng chưa
13
+ echo "Checking bun installation..."
14
+ which bun || echo "Bun not found in PATH"
15
+ echo "PATH=$PATH"
16
+
17
+ # Kiểm tra file scripts trong package.json
18
+ echo "Checking package.json scripts..."
19
+ cat package.json | grep scripts -A 10
20
 
21
+ # Khởi động ứng dụng với node thay vì bun
22
+ echo "Starting application..."
23
+ node src/app.mjs &
24
 
25
  # Kiểm tra file nginx.conf
26
  echo "Checking nginx configuration..."
27
+ cat /etc/nginx/nginx.conf | head -n 10
28
 
29
+ # Khởi động nginx
30
+ echo "Starting Nginx..."
31
+ /usr/sbin/nginx -g "daemon off;"