File size: 1,071 Bytes
33d9697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 1. 使用一个标准的、轻量的 Node.js 镜像
FROM node:18-slim

# 2. 安装 wget 并下载、安装官方的 Google Chrome
RUN apt-get update && apt-get install -y wget gnupg ca-certificates && \
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
    sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
    apt-get update && \
    apt-get install -y google-chrome-stable fonts-noto-cjk --no-install-recommends && \
    rm -rf /var/lib/apt/lists/*

# 3. 创建一个工作目录和一个非 root 用户
WORKDIR /home/pptruser/app
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
    && chown -R pptruser:pptruser /home/pptruser

# 4. 复制依赖文件
COPY --chown=pptruser:pptruser package*.json ./

# 5. 安装依赖
RUN npm install

# 6. 复制您的应用代码
COPY --chown=pptruser:pptruser . .

# 7. 切换到非 root 用户
USER pptruser

# 8. 暴露端口并启动服务
EXPOSE 7860
CMD ["node", "server.js"]