1313#
1414# HTTPS endpoint-only mode is intentionally unsupported here. Use a named
1515# gateway config when mTLS materials are needed.
16+ #
17+ # Sandbox image overrides:
18+ # OPENSHELL_E2E_DOCKER_SANDBOX_IMAGE=...
19+ # OPENSHELL_E2E_DOCKER_SANDBOX_IMAGE_PULL_POLICY=Always|IfNotPresent|Never
20+ #
21+ # The default community sandbox image uses :latest. This wrapper refreshes it
22+ # before starting the gateway, while the Docker driver defaults to IfNotPresent
23+ # so local Dockerfile-built images remain usable.
1624
1725set -euo pipefail
1826
@@ -342,6 +350,41 @@ ensure_docker_supervisor_image() {
342350 exit 2
343351}
344352
353+ image_uses_latest_tag () {
354+ local image=$1
355+ local last_component
356+
357+ # Digest references are immutable even if the tag portion says latest.
358+ if [[ " ${image} " == * @* ]]; then
359+ return 1
360+ fi
361+
362+ last_component=" ${image##*/ } "
363+ # Docker treats an omitted tag as :latest.
364+ if [[ " ${last_component} " != * :* ]]; then
365+ return 0
366+ fi
367+
368+ [[ " ${last_component} " == * :latest ]]
369+ }
370+
371+ ensure_sandbox_image_available () {
372+ local image=$1
373+
374+ if image_uses_latest_tag " ${image} " ; then
375+ echo " Refreshing latest sandbox image ${image} ..."
376+ docker_pull_with_retry " ${image} "
377+ return
378+ fi
379+
380+ if docker image inspect " ${image} " > /dev/null 2>&1 ; then
381+ return
382+ fi
383+
384+ echo " Pulling ${image} ..."
385+ docker_pull_with_retry " ${image} "
386+ }
387+
345388DAEMON_ARCH=" $( normalize_arch " $( docker info --format ' {{.Architecture}}' 2> /dev/null || true) " ) "
346389SUPERVISOR_TARGET=" $( linux_target_triple " ${DAEMON_ARCH} " ) "
347390HOST_OS=" $( uname -s) "
386429
387430DEFAULT_SANDBOX_IMAGE=" ghcr.io/nvidia/openshell-community/sandboxes/base:latest"
388431SANDBOX_IMAGE=" ${OPENSHELL_E2E_DOCKER_SANDBOX_IMAGE:- ${OPENSHELL_SANDBOX_IMAGE:- ${DEFAULT_SANDBOX_IMAGE} } } "
389- if ! docker image inspect " ${SANDBOX_IMAGE} " > /dev/null 2>&1 ; then
390- echo " Pulling ${SANDBOX_IMAGE} ..."
391- if ! docker_pull_with_retry " ${SANDBOX_IMAGE} " ; then
392- echo " ERROR: sandbox image '${SANDBOX_IMAGE} ' is not available." >&2
393- exit 2
394- fi
432+ SANDBOX_IMAGE_PULL_POLICY=" ${OPENSHELL_E2E_DOCKER_SANDBOX_IMAGE_PULL_POLICY:- ${OPENSHELL_SANDBOX_IMAGE_PULL_POLICY:- IfNotPresent} } "
433+ if ! ensure_sandbox_image_available " ${SANDBOX_IMAGE} " ; then
434+ echo " ERROR: sandbox image '${SANDBOX_IMAGE} ' is not available." >&2
435+ exit 2
395436fi
396437
397438PKI_DIR=" ${WORKDIR} /pki"
420461fi
421462
422463echo " Starting openshell-gateway on port ${HOST_PORT} (namespace: ${E2E_NAMESPACE} )..."
464+ echo " Using sandbox image: ${SANDBOX_IMAGE} (pull policy: ${SANDBOX_IMAGE_PULL_POLICY} )"
423465e2e_generate_gateway_jwt " ${JWT_DIR} "
424466
425467# Driver-specific options moved from CLI flags into a TOML config table
@@ -446,7 +488,7 @@ GATEWAY_CONFIG="${STATE_DIR}/gateway.toml"
446488 printf ' network_name = %s\n' " $( toml_string " ${DOCKER_NETWORK_NAME} " ) "
447489 printf ' grpc_endpoint = %s\n' " $( toml_string " ${GATEWAY_ENDPOINT} " ) "
448490 printf ' default_image = %s\n' " $( toml_string " ${SANDBOX_IMAGE} " ) "
449- printf ' image_pull_policy = "IfNotPresent" \n'
491+ printf ' image_pull_policy = %s \n' " $( toml_string " ${SANDBOX_IMAGE_PULL_POLICY} " ) "
450492 printf ' guest_tls_ca = %s\n' " $( toml_string " ${PKI_DIR} /ca.crt" ) "
451493 printf ' guest_tls_cert = %s\n' " $( toml_string " ${PKI_DIR} /client/tls.crt" ) "
452494 printf ' guest_tls_key = %s\n' " $( toml_string " ${PKI_DIR} /client/tls.key" ) "
0 commit comments