testno / Dockerfile
ssassxxaa002's picture
Create Dockerfile
b7a39fa verified
raw
history blame contribute delete
572 Bytes
FROM node:18-alpine
# 安装必要的工具
RUN apk add --no-cache curl bash
WORKDIR /app
# 复制 package.json 并安装依赖
COPY package*.json ./
RUN npm install --production
# 全局安装 PM2
RUN npm install -g pm2
# 复制应用代码
COPY . .
# 创建必要的目录
RUN mkdir -p /app/tmp && chmod 777 /app/tmp
# 暴露端口
EXPOSE 7860 3000
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/ || exit 1
# 使用 PM2 作为进程管理器
CMD ["pm2-runtime", "start", "index.js"]