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.
This commit is contained in:
parent
066724318a
commit
b72f1d7670
@ -1,18 +1,21 @@
|
|||||||
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library
|
ARG BASE_REGISTRY=harbor-in-k3s.cheverjohn.me/library
|
||||||
FROM ${BASE_REGISTRY}/node:20-alpine AS builder
|
FROM ${BASE_REGISTRY}/node:20-alpine AS builder
|
||||||
|
ARG APK_MIRROR=mirrors.aliyun.com
|
||||||
|
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||||
|
|
||||||
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories
|
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
|
RUN corepack enable && corepack prepare pnpm@9 --activate
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json pnpm-lock.yaml ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
RUN pnpm install --frozen-lockfile --registry=https://registry.npmmirror.com
|
RUN pnpm install --frozen-lockfile --registry=${NPM_REGISTRY}
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
FROM ${BASE_REGISTRY}/nginx:1.27-alpine
|
FROM ${BASE_REGISTRY}/nginx:1.27-alpine
|
||||||
RUN sed -i "s|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g" /etc/apk/repositories
|
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 --from=builder /app/dist /usr/share/nginx/html
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user