Skip to content

Commit 089dd9e

Browse files
committed
Enh: Show docker pull error messages
1 parent 069d59f commit 089dd9e

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/swerex/deployment/docker.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import subprocess
44
import time
55
import uuid
6-
import time
76
from typing import Any
87

98
from typing_extensions import Self
@@ -139,18 +138,18 @@ def _pull_image(self) -> None:
139138
try:
140139
_pull_image(self._config.image)
141140
except subprocess.CalledProcessError as e:
142-
msg = f"Failed to pull image {self._config.image}"
141+
msg = f"Failed to pull image {self._config.image}. "
142+
msg += f"Error: {e.stderr.decode()}"
143+
msg += f"Output: {e.output.decode()}"
143144
raise DockerPullError(msg) from e
144145

145146
@property
146147
def glibc_dockerfile(self) -> str:
147148
# will only work with glibc-based systems
148149
text = (
149150
"ARG BASE_IMAGE\n\n"
150-
151151
# Build stage for standalone Python
152152
"FROM python:3.11-slim AS builder\n"
153-
154153
# Install build dependencies
155154
"RUN apt-get update && apt-get install -y \\\n"
156155
" wget \\\n"
@@ -159,7 +158,6 @@ def glibc_dockerfile(self) -> str:
159158
" zlib1g-dev \\\n"
160159
" libssl-dev \\\n"
161160
" && rm -rf /var/lib/apt/lists/*\n\n"
162-
163161
# Download and compile Python as standalone
164162
"WORKDIR /build\n"
165163
"RUN wget https://www.python.org/ftp/python/3.11.8/Python-3.11.8.tgz \\\n"
@@ -168,35 +166,39 @@ def glibc_dockerfile(self) -> str:
168166
"RUN ./configure --prefix=/root/python3.11 --enable-shared \\\n"
169167
" && make -j$(nproc) \\\n"
170168
" && make install\n\n"
171-
172169
# Install swe-rex using the standalone Python
173170
f"RUN /root/python3.11/bin/pip3 install --no-cache-dir {PACKAGE_NAME}\n\n"
174-
175171
# Production stage
176172
"FROM $BASE_IMAGE\n"
177-
178173
# Copy the standalone Python installation
179174
f"COPY --from=builder /root/python3.11 {self._config.python_standalone_dir}/python3.11\n"
180-
181175
# Append to LD_LIBRARY_PATH instead of overwriting it
182176
f"ENV LD_LIBRARY_PATH={self._config.python_standalone_dir}/python3.11/lib:${{LD_LIBRARY_PATH}}\n"
183-
184177
# Verify installation
185178
f"RUN {self._config.python_standalone_dir}/python3.11/bin/python3 --version\n"
186179
# Create symlink to make the executable available in PATH
187180
f"RUN {self._config.python_standalone_dir}/python3.11/bin/{REMOTE_EXECUTABLE_NAME} --version\n"
188181
)
189182
return text
190-
183+
191184
def _build_image(self):
192185
dockerfile = self.glibc_dockerfile
193186
# build docker image without a tag, but get the image id
194-
image_id = subprocess.check_output(
195-
[
196-
"docker", "build", "-q", "--build-arg", f"BASE_IMAGE={self._config.image}", "-",
197-
],
198-
input=dockerfile.encode(),
199-
).decode().strip()
187+
image_id = (
188+
subprocess.check_output(
189+
[
190+
"docker",
191+
"build",
192+
"-q",
193+
"--build-arg",
194+
f"BASE_IMAGE={self._config.image}",
195+
"-",
196+
],
197+
input=dockerfile.encode(),
198+
)
199+
.decode()
200+
.strip()
201+
)
200202
return image_id
201203

202204
async def start(self):

0 commit comments

Comments
 (0)