Configurable conda/mamba channel_alias for runtime builds (#11516)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Engel Nyst
2025-12-29 00:40:57 +01:00
committed by GitHub
parent 30114666ad
commit 97654e6a5e
3 changed files with 76 additions and 0 deletions

View File

@@ -52,12 +52,16 @@ def _generate_dockerfile(
)
template = env.get_template('Dockerfile.j2')
# Allow overriding conda/mamba channel alias (e.g., to avoid anaconda.org)
channel_alias = os.getenv('OH_CONDA_CHANNEL_ALIAS', '').strip() or None
dockerfile_content = template.render(
base_image=base_image,
build_from_scratch=build_from == BuildFromImageType.SCRATCH,
build_from_versioned=build_from == BuildFromImageType.VERSIONED,
extra_deps=extra_deps if extra_deps is not None else '',
enable_browser=enable_browser,
channel_alias=channel_alias,
)
return dockerfile_content

View File

@@ -275,6 +275,9 @@ RUN \
RUN mkdir -p /openhands/micromamba/bin && \
/bin/bash -c "PREFIX_LOCATION=/openhands/micromamba BIN_FOLDER=/openhands/micromamba/bin INIT_YES=no CONDA_FORGE_YES=yes $(curl -L https://micro.mamba.pm/install.sh)" && \
/openhands/micromamba/bin/micromamba config remove channels defaults && \
{%- if channel_alias %}
/openhands/micromamba/bin/micromamba config set channel_alias '{{ channel_alias }}' && \
{%- endif %}
/openhands/micromamba/bin/micromamba config list && \
chown -R openhands:openhands /openhands/micromamba && \
# Create read-only shared access to micromamba for all users