Skip to content

Commit e35c1ff

Browse files
authored
Display real-time build logs for the agnostic image (OpenHands#2830)
* Display real-time build logs for the agnostic image and improve wget's output. * remove unused code
1 parent 34c7656 commit e35c1ff

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

containers/sandbox/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ RUN ln -s /usr/bin/python3 /usr/bin/python
3030

3131
# ==== OpenDevin Runtime Client ====
3232
RUN mkdir -p /opendevin && mkdir -p /opendevin/logs && chmod 777 /opendevin/logs
33-
RUN wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
34-
RUN bash Miniforge3-$(uname)-$(uname -m).sh -b -p /opendevin/miniforge3
33+
RUN wget --progress=bar:force -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
34+
RUN bash Miniforge3.sh -b -p /opendevin/miniforge3
3535
RUN chmod -R g+w /opendevin/miniforge3
3636
RUN bash -c ". /opendevin/miniforge3/etc/profile.d/conda.sh && conda config --set changeps1 False && conda config --append channels conda-forge"
3737
RUN echo "" > /opendevin/bash.bashrc
38+
RUN rm -f Miniforge3.sh
3839

3940
# - agentskills dependencies
4041
RUN /opendevin/miniforge3/bin/pip install --upgrade pip

opendevin/runtime/docker/image_agnostic_util.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def generate_dockerfile_content(base_image: str) -> str:
1919
'RUN mkdir -p /opendevin && mkdir -p /opendevin/logs && chmod 777 /opendevin/logs\n'
2020
'RUN echo "" > /opendevin/bash.bashrc\n'
2121
'RUN if [ ! -d /opendevin/miniforge3 ]; then \\\n'
22-
' wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" && \\\n'
23-
' bash Miniforge3-$(uname)-$(uname -m).sh -b -p /opendevin/miniforge3 && \\\n'
22+
' wget --progress=bar:force -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" && \\\n'
23+
' bash Miniforge3.sh -b -p /opendevin/miniforge3 && \\\n'
2424
' chmod -R g+w /opendevin/miniforge3 && \\\n'
2525
' bash -c ". /opendevin/miniforge3/etc/profile.d/conda.sh && conda config --set changeps1 False && conda config --append channels conda-forge"; \\\n'
2626
' fi\n'
@@ -48,15 +48,18 @@ def _build_sandbox_image(
4848
with open(f'{temp_dir}/Dockerfile', 'w') as file:
4949
file.write(dockerfile_content)
5050

51-
image, logs = docker_client.images.build(
52-
path=temp_dir, tag=target_image_name
53-
)
51+
api_client = docker_client.api
52+
build_logs = api_client.build(path=temp_dir, tag=target_image_name, rm=True, decode=True)
5453

55-
for log in logs:
56-
if 'stream' in log:
57-
print(log['stream'].strip())
54+
for log in build_logs:
55+
if 'stream' in log:
56+
print(log['stream'].strip())
57+
elif 'error' in log:
58+
logger.error(log['error'].strip())
59+
else:
60+
logger.info(str(log))
5861

59-
logger.info(f'Image {image} built successfully')
62+
logger.info(f'Image {target_image_name} built successfully')
6063
except docker.errors.BuildError as e:
6164
logger.error(f'Sandbox image build failed: {e}')
6265
raise e

0 commit comments

Comments
 (0)