File size: 1,025 Bytes
24d9623
 
9d8f153
 
341518c
24d9623
 
9d8f153
 
 
341518c
 
24d9623
341518c
 
24d9623
 
 
 
0bace88
352fa06
0bace88
 
48a00a0
 
 
 
 
 
 
352fa06
ef182a3
 
578c482
341518c
 
 
 
 
 
 
 
 
 
578c482
 
9d8f153
 
 
 
24d9623
 
 
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
FROM node:20-slim



# 创建应用目录
WORKDIR /app

# Wrangler will prompt, and thus hang if you don't specify this
ENV WRANGLER_SEND_METRICS=false

# 添加非root用户
RUN groupadd -r nodejs && useradd -r -g nodejs nodejs

# 复制项目文件
COPY package*.json ./
RUN npm install

COPY . .

# 声明所有需要的构建参数
ARG UUID
# 如果需要在容器运行时使用,转换为环境变量
ENV UUID=${UUID}

# 在 RUN 指令中使用双引号打印
RUN echo "UUID is: ${UUID}"

# 打印所有环境变量
RUN printenv

# 将环境变量写入 .dev.vars
RUN echo "UUID=${UUID}" >> .dev.vars


# 设置目录权限
RUN chown -R nodejs:nodejs /app

# 切换到非root用户
USER nodejs

# 创建必要的目录并设置权限
RUN mkdir -p /app/node_modules/.mf && \
    mkdir -p /app/.wrangler

RUN chown -R nodejs:nodejs /app/node_modules/.mf && \
    chown -R nodejs:nodejs /app/.wrangler

RUN chmod -R 777 /app/node_modules/.mf && \
    chmod -R 777 /app/.wrangler

EXPOSE 7860

CMD ["npm", "run", "start"]