From 2f103c5d4effaaf00e8605f70f39f998706288a4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 1 Jun 2026 10:56:36 +0000 Subject: [PATCH] fix: pre-download tiktoken encoding files in Dockerfile for offline support --- Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Dockerfile b/Dockerfile index 3842001e1b..15614379f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,16 @@ ADD go.mod go.sum ./ RUN go env -w GOPROXY=https://goproxy.cn,direct RUN go env -w GOSUMDB=goproxy.cn/sumdb/sum.golang.org RUN go mod download + +# Pre-download tiktoken encoding files so the container can start without internet access. +# The tiktoken-go library caches files as SHA1(url) under TIKTOKEN_CACHE_DIR. +# cl100k_base is used by gpt-3.5-turbo and gpt-4; o200k_base is used by gpt-4o. +RUN mkdir -p /tiktoken_cache && \ + wget -O /tiktoken_cache/9b5ad71b2ce5302211f9c61530b329a4922fc6a4 \ + "https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken" && \ + wget -O /tiktoken_cache/fb374d419588a4632f3f557e76b4b70aebbca790 \ + "https://openaipublic.blob.core.windows.net/encodings/o200k_base.tiktoken" + COPY . . COPY --from=builder /web/build ./web/build RUN go build -ldflags "-s -w -X 'github.com/songquanpeng/one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api @@ -39,6 +49,8 @@ RUN apk update \ && update-ca-certificates 2>/dev/null || true COPY --from=builder2 /build/one-api / +COPY --from=builder2 /tiktoken_cache /tiktoken_cache +ENV TIKTOKEN_CACHE_DIR=/tiktoken_cache EXPOSE 3000 WORKDIR /data ENTRYPOINT ["/one-api"] \ No newline at end of file