增加加速镜像

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
+22 -2
View File
@@ -1,14 +1,28 @@
# 客服云 API — 生产镜像(多阶段构建)
# build context: 仓库根目录
# docker build -f deploy/docker/Dockerfile.api -t kefu-api:latest .
#
# 国内加速(默认开启):Alpine 清华源 + goproxy.cn
# 海外构建可覆盖:
# docker build --build-arg ALPINE_MIRROR=dl-cdn.alpinelinux.org \
# --build-arg GOPROXY=https://proxy.golang.org,direct ...
FROM golang:1.24-alpine AS builder
ARG ALPINE_MIRROR=mirrors.cloud.tencent.com
ARG GOPROXY=https://goproxy.cn,direct
# 若 go.mod 要求更高版本,自动下载 toolchain
ENV GOTOOLCHAIN=auto
ENV CGO_ENABLED=0
ENV GOPROXY=${GOPROXY}
ENV GOSUMDB=sum.golang.google.cn
RUN apk add --no-cache git ca-certificates tzdata
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 git ca-certificates tzdata
WORKDIR /src
@@ -26,7 +40,13 @@ RUN GOOS=linux GOARCH=amd64 \
FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata wget \
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 ca-certificates tzdata wget \
&& adduser -D -H -u 10001 kefu
ENV TZ=Asia/Shanghai
+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