ARG NODE_IMAGE=docker.m.daocloud.io/library/node:24-alpine
ARG NGINX_IMAGE=docker.m.daocloud.io/library/nginx:1.27-alpine

FROM ${NODE_IMAGE} AS build

WORKDIR /app

RUN corepack enable

COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile

COPY . .

ARG VITE_BASE_URL=http://twin.batiao8.com
ARG VITE_APP_ID=10063
ENV VITE_BASE_URL=$VITE_BASE_URL
ENV VITE_APP_ID=$VITE_APP_ID

RUN pnpm build

FROM ${NGINX_IMAGE} AS runtime

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

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
