jljiu commited on
Commit
a59ed4e
·
verified ·
1 Parent(s): ef31697

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +53 -0
Dockerfile ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用官方的Ubuntu作为基础镜像
2
+ FROM ubuntu:latest
3
+
4
+ # 更新软件包列表并安装所需软件
5
+ RUN apt -y update && \
6
+ apt -y install curl unzip nodejs npm
7
+
8
+ # 创建项目目录并进入
9
+ WORKDIR /app
10
+
11
+ # 复制本地的js文件到容器中
12
+ COPY main.js ./
13
+
14
+ # 列出/app目录内容
15
+ RUN ls -al /app
16
+
17
+ # 安装puppeteer依赖
18
+ RUN npm install puppeteer
19
+
20
+ # 列出/app/node_modules目录内容
21
+ RUN ls -al /app/node_modules
22
+
23
+ # 列出/app/node_modules/puppeteer目录内容
24
+ RUN ls -al /app/node_modules/puppeteer
25
+
26
+
27
+ # 手动安装Chromium
28
+ RUN node node_modules/puppeteer/install.mjs
29
+ # 创建用于存放Chrome相关文件的目录
30
+ RUN mkdir -p /app/chrome
31
+ RUN ls -al /root/.cache/puppeteer/chrome
32
+ RUN ls -al /root/.cache/puppeteer/chrome-headless-shell
33
+ RUN ls -al /root/.cache/puppeteer/chrome/linux-131.0.6778.85
34
+ RUN ls -al /root/.cache/puppeteer/chrome-headless-shell/linux-131.0.6778.85
35
+ RUN ls -al /root/.cache/puppeteer/chrome/linux-131.0.6778.85/chrome-linux64
36
+ RUN ls -al /root/.cache/puppeteer/chrome-headless-shell/linux-131.0.6778.85/chrome-headless-shell-linux64
37
+
38
+
39
+ # 移动chrome可执行文件及相关到 /app/chrome 目录(假设之前下载好的文件在对应缓存目录下可获取到)
40
+ # RUN mv /root/.cache/puppeteer/chrome/linux-131.0.6778.85 /app/chrome
41
+ # RUN mv /root/.cache/puppeteer/chrome-headless-shell/linux-131.0.6778.85 /app/chrome-headless-shell
42
+ # 复制chrome - headless - shell目录及其内容
43
+ COPY /root/.cache/puppeteer/chrome-headless-shell/linux-131.0.6778.85/. /app/chrome/
44
+
45
+
46
+ # 列出/app目录内容
47
+ RUN ls -al /app/chrome
48
+
49
+ # 暴露7860端口
50
+ EXPOSE 7860
51
+
52
+ # 运行Node.js应用
53
+ CMD ["node", "main.js"]