Files
KCGL/inventory-web/Dockerfile

31 lines
948 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ---------------------------------------
# 这是开发模式 (Development Mode) 的配置
# ---------------------------------------
# 1. 使用 Node 20 的 Alpine 版本 (轻量级)
FROM node:20-alpine
# 【关键新增】安装 libc6 兼容库
# 这一步能解决 90% 的 "Cannot find module ... musl.node" 或二进制文件缺失问题
RUN apk add --no-cache libc6-compat
# 设置工作目录
WORKDIR /app
# 2. 优先复制 package.json 和 lock 文件
# 这样如果只改代码不改依赖Docker 会利用缓存跳过安装步骤,构建更快
COPY package*.json ./
# 3. 安装依赖
# 这一步会在容器内部下载适合 Alpine Linux 的依赖包
RUN npm install
# 4. 复制其余源代码
COPY . .
# 5. 暴露端口 (仅作声明,方便查看)
EXPOSE 5173
# 6. 启动开发服务器
# 必须加 --host否则只能在容器内部访问无法通过浏览器 localhost 访问
CMD ["npm", "run", "dev", "--", "--host"]