45 lines
1.3 KiB
Docker
45 lines
1.3 KiB
Docker
# 客服云前端 — 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 --registry="${NPM_REGISTRY}"
|
|
|
|
COPY web/ ./
|
|
RUN npm run build
|
|
|
|
FROM nginx:1.27-alpine
|
|
|
|
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
|
|
|
|
COPY deploy/docker/nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY --from=builder /web/dist /usr/share/nginx/html
|
|
|
|
EXPOSE 80
|
|
|
|
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=5 \
|
|
CMD wget -qO- http://127.0.0.1/healthz || exit 1
|