Files
market_page/frontend/Dockerfile
2026-02-12 21:20:00 +08:00

30 lines
702 B
Docker

# Use an official Node runtime as a parent image
FROM node:22-alpine
# Set working directory
WORKDIR /app
# Install build dependencies for native modules
RUN apk add --no-cache autoconf automake libtool make g++ zlib-dev nasm python3
# Install dependencies
COPY package.json package-lock.json* ./
RUN npm install --registry=https://registry.npmmirror.com
# 复制项目文件
COPY . .
# 接收构建参数
ARG VITE_API_URL=/api
# 设置环境变量供构建时使用
ENV VITE_API_URL=$VITE_API_URL
# 构建生产环境代码
RUN npm run build
# 暴露应用运行的端口
EXPOSE 15173
# 启动应用 (Preview 模式)
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "15173"]