Preload tiktoken encoding in Dockerfile (Lambda) (#220)

PR #193 added tiktoken preloading to Dockerfile_ecs but the same fix
was not applied to the Lambda Dockerfile. This causes a ConnectTimeout
error in network-restricted environments (e.g. Lambda in VPC without
NAT Gateway) when tiktoken tries to download cl100k_base encoding at
runtime from openaipublic.blob.core.windows.net.

Cache the encoding at build time, consistent with Dockerfile_ecs.

Related to #118
This commit is contained in:
mjkam
2026-02-19 18:00:05 +09:00
committed by GitHub
parent a150f7bb1c
commit a1844f95d4

View File

@@ -9,6 +9,10 @@ COPY requirements.txt .
RUN pip3 install -r requirements.txt -U --no-cache-dir
# Preload tiktoken encoding: https://github.com/aws-samples/bedrock-access-gateway/issues/118
ENV TIKTOKEN_CACHE_DIR=/var/task/.cache/tiktoken
RUN python3 -c 'import tiktoken_ext.openai_public as tke; tke.cl100k_base()'
# Lambda Web Adapter requires overriding the Lambda base image entrypoint
# to run the web app directly instead of the Lambda runtime handler
ENTRYPOINT []