Spaces:
Running
Running
File size: 713 Bytes
db91942 |
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 |
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 . .
设置目录权限
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"]
|