# Use an official Node runtime as a parent image FROM node:22-alpine # Set working directory WORKDIR /app # Install dependencies COPY package.json package-lock.json* ./ RUN npm install # 复制项目文件 COPY . . # 设置环境变量供构建时使用 ENV VITE_API_URL=http://localhost:8000/api # 构建生产环境代码 RUN npm run build # 暴露应用运行的端口 EXPOSE 15173 # 启动应用 (Preview 模式) CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "15173"]