# 与服务器 deploy.sh 对齐: # docker build --build-arg VERSION=$TAG -t harbor.fuhua91.com/game/sw2:$TAG . # docker push harbor.fuhua91.com/game/sw2:$TAG # 运行阶段与部署侧 frontend.Dockerfile 一致。本仓库在镜像内编译, # 产物对应部署侧的 COPY dist/。 FROM docker.m.daocloud.io/library/node:20-alpine AS build WORKDIR /src ENV COREPACK_NPM_REGISTRY=https://registry.npmmirror.com RUN corepack enable && corepack prepare pnpm@9.15.9 --activate COPY package.json pnpm-lock.yaml ./ RUN pnpm config set registry https://registry.npmmirror.com \ && pnpm install --frozen-lockfile COPY . . RUN pnpm run build FROM docker.m.daocloud.io/nginx:1.28-alpine@sha256:a8b39bd9cf0f83869a2162827a0caf6137ddf759d50a171451b335cecc87d236 ARG VERSION LABEL org.opencontainers.image.revision=$VERSION COPY nginx.sw2.conf /etc/nginx/conf.d/default.conf COPY --from=build /src/dist /usr/share/nginx/html/ RUN printf '%s\n' "$VERSION" > /usr/share/nginx/html/version.txt HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \ CMD wget -q -O /dev/null http://127.0.0.1/healthz || exit 1