Skip to content

Commit 2e64b42

Browse files
lroolleclaude
andcommitted
fix(build): proxy-aware version resolution and Docker builds
- version resolution: replace npm view with direct registry.npmjs.org curl; npm view honored .npmrc registry (e.g. npmmirror) which could return stale metadata for recently-republished packages - Docker build: forward HTTP_PROXY/HTTPS_PROXY from host env to all docker build/buildx commands via BuildKit predefined ARGs - proxy URL rewrite: 127.0.0.1/localhost -> host.docker.internal so build containers reach the host proxy instead of own loopback - verbose proxy logging in install-agent-tooling.sh and version-upgrade.sh Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7a8f094 commit 2e64b42

6 files changed

Lines changed: 78 additions & 13 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Created by https://www.toptal.com/developers/gitignore/api/node
22
# Edit at https://www.toptal.com/developers/gitignore?templates=node
33

4+
/AGENTS.md
5+
/.cctrace
46
.claude/
57
*.bak
68

Makefile

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ RUST_TARGETS ?= wasm32-unknown-unknown
4444
DOCKER_BUILD_EXTRA_ARGS ?=
4545
SKIP_BUILD_NETWORK_CHECK ?= 0
4646

47+
# Forward host proxy env vars to Docker build (BuildKit predefined ARGs —
48+
# available in all stages without Dockerfile ARG declarations, excluded
49+
# from cache key so proxy changes don't bust layer cache).
50+
# Rewrite localhost proxy addresses: 127.0.0.1/localhost on the host is the
51+
# container's own loopback during build — host.docker.internal reaches the host.
52+
_dproxy = $(subst ://localhost,://host.docker.internal,$(subst ://127.0.0.1,://host.docker.internal,$1))
53+
PROXY_BUILD_ARGS := \
54+
$(if $(HTTP_PROXY),--build-arg HTTP_PROXY=$(call _dproxy,$(HTTP_PROXY))) \
55+
$(if $(HTTPS_PROXY),--build-arg HTTPS_PROXY=$(call _dproxy,$(HTTPS_PROXY))) \
56+
$(if $(http_proxy),--build-arg http_proxy=$(call _dproxy,$(http_proxy))) \
57+
$(if $(https_proxy),--build-arg https_proxy=$(call _dproxy,$(https_proxy))) \
58+
$(if $(NO_PROXY),--build-arg NO_PROXY=$(NO_PROXY)) \
59+
$(if $(no_proxy),--build-arg no_proxy=$(no_proxy))
60+
61+
DOCKER_BUILD_FLAGS = $(PROXY_BUILD_ARGS) $(DOCKER_BUILD_EXTRA_ARGS)
62+
4763
TOOLCHAIN_BUILD_ARGS := \
4864
--build-arg NODE_MAJOR=$(NODE_MAJOR) \
4965
--build-arg GO_VERSION=$(GO_VERSION) \
@@ -112,7 +128,7 @@ build-network-check:
112128
printf '%s\n' \
113129
'FROM node:$(NODE_MAJOR)-bookworm-slim' \
114130
'RUN node -e "require('\''dns'\'').lookup('\''registry.npmjs.org'\'',{all:true},(e,a)=>{if(e){console.error(e);process.exit(1)};console.log(a.map(x=>x.address).slice(0,3).join('\'','\''))})"' \
115-
| docker build $(DOCKER_BUILD_EXTRA_ARGS) --progress=plain --no-cache -f - . >/dev/null; \
131+
| docker build $(DOCKER_BUILD_FLAGS) --progress=plain --no-cache -f - . >/dev/null; \
116132
fi
117133

118134
build-main: build-network-check
@@ -159,23 +175,23 @@ build-main: build-network-check
159175
fi; \
160176
fi
161177
@echo "Hint: override via GO_VERSION=... CLAUDE_CODE_VERSION=... or run 'make versions-pin'"
162-
docker build $(DOCKER_BUILD_EXTRA_ARGS) -f $(DOCKERFILE) $(MAIN_BUILD_ARGS) -t $(MAIN_IMAGE) .
178+
docker build $(DOCKER_BUILD_FLAGS) -f $(DOCKERFILE) $(MAIN_BUILD_ARGS) -t $(MAIN_IMAGE) .
163179
@echo "✅ Build completed: $(MAIN_IMAGE)"
164180

165181
rebuild:
166182
@echo "🔨 Rebuilding Docker image (no cache) with $(DOCKERFILE)..."
167-
docker build $(DOCKER_BUILD_EXTRA_ARGS) -f $(DOCKERFILE) --no-cache $(MAIN_BUILD_ARGS) -t $(MAIN_IMAGE) .
183+
docker build $(DOCKER_BUILD_FLAGS) -f $(DOCKERFILE) --no-cache $(MAIN_BUILD_ARGS) -t $(MAIN_IMAGE) .
168184
@echo "✅ Rebuild completed: $(MAIN_IMAGE)"
169185

170186

171187
build-core:
172188
@echo "🔨 Building stable core image..."
173-
docker build $(DOCKER_BUILD_EXTRA_ARGS) -f $(DOCKERFILE) --target agent-base $(CORE_BUILD_ARGS) -t $(CORE_IMAGE) .
189+
docker build $(DOCKER_BUILD_FLAGS) -f $(DOCKERFILE) --target agent-base $(CORE_BUILD_ARGS) -t $(CORE_IMAGE) .
174190
@echo "✅ Core build completed: $(CORE_IMAGE)"
175191

176192
build-rust-image: build-network-check
177193
@echo "🔨 Building Rust Docker image..."
178-
docker build $(DOCKER_BUILD_EXTRA_ARGS) -f $(RUST_DOCKERFILE) \
194+
docker build $(DOCKER_BUILD_FLAGS) -f $(RUST_DOCKERFILE) \
179195
--build-arg BASE_IMAGE=$(CORE_IMAGE) \
180196
$(RUST_BUILD_ARGS) \
181197
-t $(RUST_IMAGE) .
@@ -192,27 +208,27 @@ build-all:
192208

193209
buildx:
194210
@echo "🔨 Building with docker buildx..."
195-
docker buildx build -f $(DOCKERFILE) --load $(MAIN_BUILD_ARGS) -t $(MAIN_IMAGE) .
211+
docker buildx build $(DOCKER_BUILD_FLAGS) -f $(DOCKERFILE) --load $(MAIN_BUILD_ARGS) -t $(MAIN_IMAGE) .
196212
@echo "✅ Buildx completed: $(MAIN_IMAGE)"
197213

198214
buildx-multi:
199215
@echo "🔨 Building multi-arch images for amd64 and arm64..."
200-
docker buildx build -f $(DOCKERFILE) --platform $(MULTI_ARCH_PLATFORMS) \
216+
docker buildx build $(DOCKER_BUILD_FLAGS) -f $(DOCKERFILE) --platform $(MULTI_ARCH_PLATFORMS) \
201217
$(MAIN_BUILD_ARGS) \
202218
--push -t $(MAIN_IMAGE) .
203219
@echo "✅ Multi-arch build completed and pushed: $(MAIN_IMAGE)"
204220

205221
buildx-multi-rust:
206222
@echo "🔨 Building multi-arch Rust images for amd64 and arm64..."
207-
docker buildx build -f $(RUST_DOCKERFILE) --platform $(MULTI_ARCH_PLATFORMS) \
223+
docker buildx build $(DOCKER_BUILD_FLAGS) -f $(RUST_DOCKERFILE) --platform $(MULTI_ARCH_PLATFORMS) \
208224
--build-arg BASE_IMAGE=$(MAIN_IMAGE) \
209225
$(RUST_BUILD_ARGS) \
210226
--push -t $(RUST_IMAGE) .
211227
@echo "✅ Multi-arch Rust build completed and pushed: $(RUST_IMAGE)"
212228

213229
buildx-multi-local:
214230
@echo "🔨 Building multi-arch images locally..."
215-
docker buildx build -f $(DOCKERFILE) --platform $(MULTI_ARCH_PLATFORMS) \
231+
docker buildx build $(DOCKER_BUILD_FLAGS) -f $(DOCKERFILE) --platform $(MULTI_ARCH_PLATFORMS) \
216232
$(MAIN_BUILD_ARGS) \
217233
-t $(MAIN_IMAGE) .
218234
@echo "✅ Multi-arch build completed locally: $(MAIN_IMAGE)"

scripts/install-agent-tooling.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,23 @@ download_to() {
118118
curl -fsSL "$url" -o "$dest"
119119
}
120120

121+
log_proxy_config() {
122+
local has_proxy=0
123+
for var in HTTP_PROXY HTTPS_PROXY http_proxy https_proxy NO_PROXY no_proxy; do
124+
if [ -n "${!var:-}" ]; then
125+
log " $var=${!var}"
126+
has_proxy=1
127+
fi
128+
done
129+
if [ "$has_proxy" -eq 0 ]; then
130+
log " (no proxy configured)"
131+
fi
132+
}
133+
121134
install_npm_agent_tooling() {
122135
log "Installing npm agent tooling"
136+
log "Proxy config:"
137+
log_proxy_config
123138
log "Requested versions: claude=${CLAUDE_CODE_VERSION} codex=${CODEX_VERSION} gemini=${GEMINI_CLI_VERSION} grok=${GROK_CLI_VERSION}"
124139

125140
mkdir -p "$DEVA_HOME/.npm-global" "$DEVA_HOME/.local/bin"

scripts/release-utils.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,20 @@ format_datetime() {
175175
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
176176
# Version Fetching (by type)
177177
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
178+
_npm_registry_latest() {
179+
curl -fsSL --max-time 10 \
180+
"https://registry.npmjs.org/-/package/$1/dist-tags" 2>/dev/null | \
181+
sed -n 's/.*"latest":"\([^"]*\)".*/\1/p'
182+
}
183+
178184
fetch_latest_version() {
179185
local tool=$1
180186
local type=$(get_tool_field "$tool" type)
181187
local source=$(get_tool_field "$tool" source)
182188

183189
case $type in
184190
npm)
185-
npm view "$source" version 2>/dev/null || echo ""
191+
_npm_registry_latest "$source"
186192
;;
187193
github-release)
188194
gh api "repos/$source/releases/latest" --jq '.tag_name' 2>/dev/null || echo ""
@@ -203,8 +209,9 @@ fetch_version_date() {
203209
case $type in
204210
npm)
205211
local v=$(normalize_version "$version")
206-
npm view "$source@$v" time --json 2>/dev/null | \
207-
jq -r --arg ver "$v" '.[$ver] // .' 2>/dev/null | head -1 || echo ""
212+
local encoded=${source/\//%2f}
213+
curl -fsSL --max-time 10 "https://registry.npmjs.org/$encoded" 2>/dev/null | \
214+
jq -r --arg ver "$v" '.time[$ver] // empty' 2>/dev/null | head -1 || echo ""
208215
;;
209216
github-release)
210217
gh api "repos/$source/releases/tags/$version" --jq '.published_at' 2>/dev/null || echo ""

scripts/update-version-pins.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ EOF
1919
}
2020

2121
fetch_npm_version() {
22-
npm view "$1" version 2>/dev/null || true
22+
curl -fsSL --max-time 10 \
23+
"https://registry.npmjs.org/-/package/$1/dist-tags" 2>/dev/null | \
24+
sed -n 's/.*"latest":"\([^"]*\)".*/\1/p'
2325
}
2426

2527
fetch_latest_git_tag() {

scripts/version-upgrade.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ source "$SCRIPT_DIR/version-pins.sh"
2828
CHECK_IMAGE=${MAIN_IMAGE:-ghcr.io/thevibeworks/deva:latest}
2929
BUILD_IMAGE=${BUILD_IMAGE:-ghcr.io/thevibeworks/deva:latest}
3030
CORE_IMAGE=${CORE_IMAGE:-ghcr.io/thevibeworks/deva:core}
31+
32+
# Forward host proxy env vars to Docker build stages.
33+
# Rewrite 127.0.0.1/localhost → host.docker.internal so the build
34+
# container reaches the host's proxy instead of its own loopback.
35+
_dproxy() { sed 's|://127\.0\.0\.1|://host.docker.internal|g; s|://localhost|://host.docker.internal|g' <<< "$1"; }
36+
PROXY_ARGS=()
37+
[[ -n ${HTTP_PROXY:-} ]] && PROXY_ARGS+=(--build-arg "HTTP_PROXY=$(_dproxy "$HTTP_PROXY")")
38+
[[ -n ${HTTPS_PROXY:-} ]] && PROXY_ARGS+=(--build-arg "HTTPS_PROXY=$(_dproxy "$HTTPS_PROXY")")
39+
[[ -n ${http_proxy:-} ]] && PROXY_ARGS+=(--build-arg "http_proxy=$(_dproxy "$http_proxy")")
40+
[[ -n ${https_proxy:-} ]] && PROXY_ARGS+=(--build-arg "https_proxy=$(_dproxy "$https_proxy")")
41+
[[ -n ${NO_PROXY:-} ]] && PROXY_ARGS+=(--build-arg "NO_PROXY=$NO_PROXY")
42+
[[ -n ${no_proxy:-} ]] && PROXY_ARGS+=(--build-arg "no_proxy=$no_proxy")
3143
RUST_IMAGE=${RUST_IMAGE:-ghcr.io/thevibeworks/deva:rust}
3244
DOCKERFILE=${DOCKERFILE:-Dockerfile}
3345
RUST_DOCKERFILE=${RUST_DOCKERFILE:-Dockerfile.rust}
@@ -200,8 +212,17 @@ main() {
200212
echo -e "${GREEN}Proceeding with build...${RESET}"
201213
echo ""
202214

215+
if [[ ${#PROXY_ARGS[@]} -gt 0 ]]; then
216+
echo -e "${DIM}Proxy forwarding to Docker build:${RESET}"
217+
for _pa in "${PROXY_ARGS[@]}"; do
218+
echo -e " ${DIM}${_pa#--build-arg }${RESET}"
219+
done
220+
echo ""
221+
fi
222+
203223
section "Building Core Image"
204224
docker build -f "$DOCKERFILE" \
225+
${PROXY_ARGS[@]+"${PROXY_ARGS[@]}"} \
205226
--target agent-base \
206227
--build-arg NODE_MAJOR="$NODE_MAJOR" \
207228
--build-arg GO_VERSION="$GO_VERSION" \
@@ -215,6 +236,7 @@ main() {
215236
echo ""
216237
section "Building Main Image"
217238
docker build -f "$DOCKERFILE" \
239+
${PROXY_ARGS[@]+"${PROXY_ARGS[@]}"} \
218240
--build-arg NODE_MAJOR="$NODE_MAJOR" \
219241
--build-arg GO_VERSION="$GO_VERSION" \
220242
--build-arg PYTHON_VERSION="$PYTHON_VERSION" \
@@ -233,6 +255,7 @@ main() {
233255
echo ""
234256
section "Building Rust Image"
235257
docker build -f "$RUST_DOCKERFILE" \
258+
${PROXY_ARGS[@]+"${PROXY_ARGS[@]}"} \
236259
--build-arg BASE_IMAGE="$CORE_IMAGE" \
237260
--build-arg CLAUDE_CODE_VERSION="$claude_ver" \
238261
--build-arg CCTRACE_VERSION="$cctrace_ver" \

0 commit comments

Comments
 (0)