From 9b1338a35656d9753f703b19d88408b76070d9dd Mon Sep 17 00:00:00 2001 From: samanhappy Date: Fri, 2 May 2025 12:40:44 +0800 Subject: [PATCH] feat: add support for HTTP_PROXY and HTTPS_PROXY environment variables in Dockerfile and entrypoint script (#42) --- Dockerfile | 6 ++++++ entrypoint.sh | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Dockerfile b/Dockerfile index 18588c7..2068dd3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,12 @@ FROM python:3.13-slim-bookworm AS base COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ +# 添加 HTTP_PROXY 和 HTTPS_PROXY 环境变量 +ARG HTTP_PROXY="" +ARG HTTPS_PROXY="" +ENV HTTP_PROXY=$HTTP_PROXY +ENV HTTPS_PROXY=$HTTPS_PROXY + RUN apt-get update && apt-get install -y curl gnupg git \ && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ && apt-get install -y nodejs \ diff --git a/entrypoint.sh b/entrypoint.sh index 47cb5c1..999f05b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,6 +4,19 @@ NPM_REGISTRY=${NPM_REGISTRY:-https://registry.npmjs.org/} echo "Setting npm registry to ${NPM_REGISTRY}" npm config set registry "$NPM_REGISTRY" +# 处理 HTTP_PROXY 和 HTTPS_PROXY 环境变量 +if [ -n "$HTTP_PROXY" ]; then + echo "Setting HTTP proxy to ${HTTP_PROXY}" + npm config set proxy "$HTTP_PROXY" + export HTTP_PROXY="$HTTP_PROXY" +fi + +if [ -n "$HTTPS_PROXY" ]; then + echo "Setting HTTPS proxy to ${HTTPS_PROXY}" + npm config set https-proxy "$HTTPS_PROXY" + export HTTPS_PROXY="$HTTPS_PROXY" +fi + echo "Using REQUEST_TIMEOUT: $REQUEST_TIMEOUT" echo "Using UV_PYTHON_INSTALL_MIRROR: $UV_PYTHON_INSTALL_MIRROR"