muyu-portal/Dockerfile
kae b72f1d7670 feat(deploy): parameterize registry and mirror via ARG for cross-region builds
Convert hardcoded BASE_REGISTRY, APK_MIRROR, and NPM_REGISTRY values to
ARG in both builder and runtime stages. CI defaults (Harbor + Aliyun +
npmmirror) remain in Dockerfile ARG defaults; overseas builds override
via --build-arg.
2026-07-06 00:20:40 +09:00

25 lines
819 B
Docker

ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library
FROM ${BASE_REGISTRY}/node:20-alpine AS builder
ARG APK_MIRROR=mirrors.aliyun.com
ARG NPM_REGISTRY=https://registry.npmmirror.com
RUN [ -n "$APK_MIRROR" ] && sed -i "s|dl-cdn.alpinelinux.org|${APK_MIRROR}|g" /etc/apk/repositories || true
RUN corepack enable && corepack prepare pnpm@9 --activate
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --registry=${NPM_REGISTRY}
COPY . .
RUN pnpm build
FROM ${BASE_REGISTRY}/nginx:1.27-alpine
ARG APK_MIRROR=mirrors.aliyun.com
RUN [ -n "$APK_MIRROR" ] && sed -i "s|dl-cdn.alpinelinux.org|${APK_MIRROR}|g" /etc/apk/repositories || true
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]