# 开发环境 Dockerfile FROM node:18-alpine # 设置工作目录 WORKDIR /app # 安装curl用于健康检查 RUN apk add --no-cache curl # 配置npm使用阿里云镜像 RUN npm config set registry https://registry.npmmirror.com # 安装依赖 COPY package*.json ./ RUN npm install # 复制源代码(volume会覆盖) COPY . . # 暴露端口 EXPOSE 3001 # 健康检查 HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:3001 || exit 1 # 启动开发服务器 CMD ["npm", "run", "dev"]