From 207b63c79a87e40427950d881c221acc623d9fb6 Mon Sep 17 00:00:00 2001 From: "Jiaxiao (mossaka) Zhou" Date: Sat, 21 Feb 2026 01:00:51 +0000 Subject: [PATCH] Pre-seed Maven/Gradle/sbt proxy config in agent container Java build tools do not honor HTTP_PROXY/HTTPS_PROXY env vars and need explicit proxy configuration. Pre-seed these files in the container entrypoint so JVM-based builds work automatically: - ~/.m2/settings.xml (Maven proxy) - ~/.gradle/gradle.properties (Gradle proxy) - JAVA_TOOL_OPTIONS with proxy JVM flags (sbt/generic Java) This unblocks Java, Kotlin, Clojure, and Scala builds without requiring the agent to discover the proxy configuration. Co-Authored-By: Claude Opus 4.6 --- containers/agent/entrypoint.sh | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/containers/agent/entrypoint.sh b/containers/agent/entrypoint.sh index 4f8170c8..17eabc74 100644 --- a/containers/agent/entrypoint.sh +++ b/containers/agent/entrypoint.sh @@ -162,6 +162,66 @@ if [ -n "$CLAUDE_CODE_API_KEY_HELPER" ]; then fi fi +# Pre-seed JVM build tool proxy configuration +# Java build tools (Maven, Gradle, sbt) do not honor HTTP_PROXY/HTTPS_PROXY env vars +# and need explicit proxy configuration files +if [ -n "$HTTP_PROXY" ]; then + # Extract proxy host and port from HTTP_PROXY (format: http://IP:PORT) + PROXY_HOST="${HTTP_PROXY#http://}" + PROXY_HOST="${PROXY_HOST%:*}" + PROXY_PORT="${SQUID_PROXY_PORT:-3128}" + + # Determine path prefix for config files (chroot-aware, same pattern as .claude.json) + if [ "${AWF_CHROOT_ENABLED}" = "true" ]; then + JVM_HOME_PREFIX="/host${HOME}" + else + JVM_HOME_PREFIX="${HOME}" + fi + + echo "[entrypoint] Pre-seeding JVM build tool proxy configuration (${PROXY_HOST}:${PROXY_PORT})..." + + # Maven proxy config (~/.m2/settings.xml) + mkdir -p "${JVM_HOME_PREFIX}/.m2" + cat > "${JVM_HOME_PREFIX}/.m2/settings.xml" << MAVEN_EOF + + + + awf-http + true + http + ${PROXY_HOST} + ${PROXY_PORT} + + + awf-https + true + https + ${PROXY_HOST} + ${PROXY_PORT} + + + +MAVEN_EOF + chown awfuser:awfuser "${JVM_HOME_PREFIX}/.m2/settings.xml" 2>/dev/null || true + echo "[entrypoint] ✓ Created Maven proxy config (${JVM_HOME_PREFIX}/.m2/settings.xml)" + + # Gradle proxy config (~/.gradle/gradle.properties) + mkdir -p "${JVM_HOME_PREFIX}/.gradle" + cat > "${JVM_HOME_PREFIX}/.gradle/gradle.properties" << GRADLE_EOF +systemProp.http.proxyHost=${PROXY_HOST} +systemProp.http.proxyPort=${PROXY_PORT} +systemProp.https.proxyHost=${PROXY_HOST} +systemProp.https.proxyPort=${PROXY_PORT} +GRADLE_EOF + chown awfuser:awfuser "${JVM_HOME_PREFIX}/.gradle/gradle.properties" 2>/dev/null || true + echo "[entrypoint] ✓ Created Gradle proxy config (${JVM_HOME_PREFIX}/.gradle/gradle.properties)" + + # sbt/JVM proxy config via JAVA_TOOL_OPTIONS + # This covers sbt and any JVM tool that reads standard system properties + export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:-} -Dhttp.proxyHost=${PROXY_HOST} -Dhttp.proxyPort=${PROXY_PORT} -Dhttps.proxyHost=${PROXY_HOST} -Dhttps.proxyPort=${PROXY_PORT}" + echo "[entrypoint] ✓ Set JAVA_TOOL_OPTIONS with proxy flags" +fi + # Print proxy environment echo "[entrypoint] Proxy configuration:" echo "[entrypoint] HTTP_PROXY=$HTTP_PROXY"