xwwww commited on
Commit
40c18b8
·
verified ·
1 Parent(s): 60a363c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -12
Dockerfile CHANGED
@@ -1,27 +1,42 @@
1
- # Use an official Node.js runtime as a parent image
2
  FROM node:18
3
- #RUN useradd -m -u 1000 user
4
- # Set the working directory in the container
5
 
 
6
  WORKDIR /home/user/app
 
 
 
 
 
 
 
 
 
 
 
 
7
  USER user
8
  ENV HOME=/home/user \
9
  PATH=/home/user/.local/bin:$PATH
10
- # Install git to clone the repository
11
- RUN apt-get update && apt-get install -y git
12
 
13
- # Clone the repository from GitHub
14
  RUN git clone https://github.com/KarinJS/karin-puppeteer.git .
15
 
16
- # Install dependencies
 
 
 
17
  RUN npm install
18
 
 
 
19
 
20
- # Make port 3000 available to the world outside this container
21
  EXPOSE 7860
22
 
23
- # Define environment variable
24
- ENV NODE_ENV=production
25
-
26
- # Run the app
27
  CMD ["node", "."]
 
 
 
 
 
1
+ # 使用官方Node.js作为基础镜像
2
  FROM node:18
 
 
3
 
4
+ # 创建工作目录
5
  WORKDIR /home/user/app
6
+
7
+ # 安装 git
8
+ RUN apt-get update && apt-get install -y git
9
+
10
+ # 如果用户1000存在,则不创建;否则创建
11
+ RUN if id "user" >/dev/null 2>&1; then \
12
+ echo "User exists"; \
13
+ else \
14
+ useradd -m -u 1000 user; \
15
+ fi
16
+
17
+ # 设置用户
18
  USER user
19
  ENV HOME=/home/user \
20
  PATH=/home/user/.local/bin:$PATH
 
 
21
 
22
+ # GitHub克隆代码库
23
  RUN git clone https://github.com/KarinJS/karin-puppeteer.git .
24
 
25
+ # 切换回root用户以安装npm依赖
26
+ USER root
27
+
28
+ # 安装项目依赖
29
  RUN npm install
30
 
31
+ # 切换回用户
32
+ USER user
33
 
34
+ # 暴露应用运行的端口
35
  EXPOSE 7860
36
 
37
+ # 启动应用
 
 
 
38
  CMD ["node", "."]
39
+
40
+
41
+
42
+