增加加速镜像

This commit is contained in:
yml2213
2026-07-15 16:09:05 +08:00
parent 0d3543fd4b
commit 3dbd81cf49
3 changed files with 65 additions and 6 deletions
+21 -2
View File
@@ -1,18 +1,37 @@
# 客服云前端 — Nginx 托管静态资源并反代 API / 文件
# build context: 仓库根目录
#
# 国内加速(默认开启):Alpine 腾讯云源 + npmmirror
# 海外构建可覆盖:
# docker build --build-arg ALPINE_MIRROR=dl-cdn.alpinelinux.org \
# --build-arg NPM_REGISTRY=https://registry.npmjs.org ...
FROM node:22-alpine AS builder
ARG ALPINE_MIRROR=mirrors.cloud.tencent.com
ARG NPM_REGISTRY=https://registry.npmmirror.com
RUN set -eux; \
if [ -n "${ALPINE_MIRROR}" ]; then \
sed -i "s#dl-cdn.alpinelinux.org#${ALPINE_MIRROR}#g" /etc/apk/repositories; \
fi
WORKDIR /web
COPY web/package.json web/package-lock.json ./
RUN npm ci
RUN npm ci --registry="${NPM_REGISTRY}"
COPY web/ ./
RUN npm run build
FROM nginx:1.27-alpine
RUN apk add --no-cache tzdata \
ARG ALPINE_MIRROR=mirrors.cloud.tencent.com
RUN set -eux; \
if [ -n "${ALPINE_MIRROR}" ]; then \
sed -i "s#dl-cdn.alpinelinux.org#${ALPINE_MIRROR}#g" /etc/apk/repositories; \
fi; \
apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo Asia/Shanghai > /etc/timezone