From a6f303555f02ef84b7b6a5ac8157eb3ae42c32e2 Mon Sep 17 00:00:00 2001 From: AlexCuadron Date: Mon, 17 Feb 2025 05:50:08 +0000 Subject: [PATCH 1/4] fix: Add non-interactive Docker build flags to prevent stuck prompts --- openhands/runtime/builder/docker.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openhands/runtime/builder/docker.py b/openhands/runtime/builder/docker.py index dbbea66daed0..b9aed2ddb8d3 100644 --- a/openhands/runtime/builder/docker.py +++ b/openhands/runtime/builder/docker.py @@ -109,11 +109,18 @@ def build( target_image_repo, target_image_source_tag = target_image_hash_name.split(':') target_image_tag = tags[1].split(':')[1] if len(tags) > 1 else None + # Set environment variables for non-interactive Docker builds + os.environ['DOCKER_BUILDKIT'] = '1' + os.environ['DOCKER_SCAN_SUGGEST'] = 'false' + os.environ['DEBIAN_FRONTEND'] = 'noninteractive' + buildx_cmd = [ 'docker', 'buildx', 'build', '--progress=plain', + '--force-rm', # Force remove intermediate containers + '--rm', # Remove intermediate containers after a successful build f'--build-arg=OPENHANDS_RUNTIME_VERSION={oh_version}', f'--build-arg=OPENHANDS_RUNTIME_BUILD_TIME={datetime.datetime.now().isoformat()}', f'--tag={target_image_hash_name}', From c6ef06f51674429044c232fc4cca1d0d4dc87a2c Mon Sep 17 00:00:00 2001 From: AlexCuadron Date: Mon, 17 Feb 2025 05:55:44 +0000 Subject: [PATCH 2/4] fix: Prevent interactive prompts in Docker build by setting non-interactive environment and using force flags --- .../utils/runtime_templates/Dockerfile.j2 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/openhands/runtime/utils/runtime_templates/Dockerfile.j2 b/openhands/runtime/utils/runtime_templates/Dockerfile.j2 index ef073a6a7a84..05679ff2cf55 100644 --- a/openhands/runtime/utils/runtime_templates/Dockerfile.j2 +++ b/openhands/runtime/utils/runtime_templates/Dockerfile.j2 @@ -12,8 +12,13 @@ ENV POETRY_VIRTUALENVS_PATH=/openhands/poetry \ {% macro setup_base_system() %} +# Set non-interactive environment variables +ENV DEBIAN_FRONTEND=noninteractive \ + DEBCONF_NONINTERACTIVE_SEEN=true + # Install base system dependencies RUN apt-get update && \ + echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \ apt-get install -y --no-install-recommends \ wget curl sudo apt-utils git jq tmux \ {%- if 'ubuntu' in base_image and (base_image.endswith(':latest') or base_image.endswith(':24.04')) -%} @@ -22,8 +27,9 @@ RUN apt-get update && \ libgl1-mesa-glx \ {% endif -%} libasound2-plugins libatomic1 && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* + apt-get clean -y && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Remove UID 1000 if it's called pn--this fixes the nikolaik image for ubuntu users RUN if getent passwd 1000 | grep -q pn; then userdel pn; fi @@ -93,8 +99,10 @@ RUN \ chmod -R g+rws /openhands/poetry && \ mkdir -p /openhands/workspace && chmod -R g+rws,o+rw /openhands/workspace && \ # Clean up - apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ - /openhands/micromamba/bin/micromamba clean --all + apt-get clean -y && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ + yes | /openhands/micromamba/bin/micromamba clean --all --force-pkgs-dirs {% endmacro %} From c07cfa4619dc3320f738e10e246dec3d866d71bd Mon Sep 17 00:00:00 2001 From: AlexCuadron Date: Mon, 17 Feb 2025 05:57:53 +0000 Subject: [PATCH 3/4] fix: Prevent interactive prompts in Docker build by setting non-interactive environment and using force flags --- openhands/runtime/utils/runtime_templates/Dockerfile.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openhands/runtime/utils/runtime_templates/Dockerfile.j2 b/openhands/runtime/utils/runtime_templates/Dockerfile.j2 index 05679ff2cf55..765a7e96fb1f 100644 --- a/openhands/runtime/utils/runtime_templates/Dockerfile.j2 +++ b/openhands/runtime/utils/runtime_templates/Dockerfile.j2 @@ -122,8 +122,8 @@ RUN mkdir -p /openhands/micromamba/bin && \ /openhands/micromamba/bin/micromamba config list # Create the openhands virtual environment and install poetry and python -RUN /openhands/micromamba/bin/micromamba create -n openhands -y && \ - /openhands/micromamba/bin/micromamba install -n openhands -c conda-forge poetry python=3.12 -y +RUN CONDA_ALWAYS_YES=true /openhands/micromamba/bin/micromamba create -n openhands -y && \ + CONDA_ALWAYS_YES=true /openhands/micromamba/bin/micromamba install -n openhands -c conda-forge poetry python=3.12 -y # Create a clean openhands directory including only the pyproject.toml, poetry.lock and openhands/__init__.py RUN \ From b638886af0679d0bc8178c0d925ca9d90c0fab30 Mon Sep 17 00:00:00 2001 From: AlexCuadron Date: Mon, 17 Feb 2025 06:04:08 +0000 Subject: [PATCH 4/4] fix: Prevent interactive prompts during Playwright installation --- openhands/runtime/utils/runtime_templates/Dockerfile.j2 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openhands/runtime/utils/runtime_templates/Dockerfile.j2 b/openhands/runtime/utils/runtime_templates/Dockerfile.j2 index 765a7e96fb1f..94320169debf 100644 --- a/openhands/runtime/utils/runtime_templates/Dockerfile.j2 +++ b/openhands/runtime/utils/runtime_templates/Dockerfile.j2 @@ -89,8 +89,10 @@ RUN \ /openhands/micromamba/bin/micromamba run -n openhands poetry install --only main,runtime --no-interaction --no-root && \ # Update and install additional tools apt-get update && \ - /openhands/micromamba/bin/micromamba run -n openhands poetry run pip install playwright && \ - /openhands/micromamba/bin/micromamba run -n openhands poetry run playwright install --with-deps chromium && \ + # Install playwright and its dependencies non-interactively + DEBIAN_FRONTEND=noninteractive /openhands/micromamba/bin/micromamba run -n openhands poetry run pip install playwright && \ + DEBIAN_FRONTEND=noninteractive PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 /openhands/micromamba/bin/micromamba run -n openhands poetry run playwright install --with-deps chromium && \ + yes | /openhands/micromamba/bin/micromamba run -n openhands poetry run playwright install chromium && \ # Set environment variables echo "OH_INTERPRETER_PATH=$(/openhands/micromamba/bin/micromamba run -n openhands poetry run python -c "import sys; print(sys.executable)")" >> /etc/environment && \ # Clear caches