# 使用 Node 作为基础镜像
FROM registry.cn-hangzhou.aliyuncs.com/zsanyu/rcsc:amd64-node-21 as builder

# 设置工作目录
WORKDIR /app

# 拷贝package.json和package-lock.json
COPY package*.json ./

# 安装依赖
RUN npm config set registry https://registry.npmmirror.com && \
    npm install

# 将项目文件拷贝到工作目录
COPY . .

# 构建项目
RUN npx vite build

FROM nginx:stable-alpine

RUN rm -rf /etc/nginx/conf.d/default.conf

COPY --from=builder /app/dist /usr/share/nginx/html
COPY --from=builder /app/default-nginx.conf /etc/nginx/conf.d/default.conf

# 暴露端口
EXPOSE 80
