Skip to content

Commit 1aceb88

Browse files
committed
fix: sudo for apt-get in install commands, add golang/corepack/sudo to Dockerfile
1 parent 398a6fd commit 1aceb88

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ RUN cargo build --release && strip target/release/term-executor
1111
# ── Runtime stage ──
1212
FROM debian:bookworm-slim
1313
RUN apt-get update && apt-get install -y --no-install-recommends \
14-
ca-certificates git curl libssl3 \
14+
ca-certificates git curl libssl3 sudo \
1515
python3 python3-pip python3-venv \
1616
build-essential nodejs npm \
17+
golang-go \
1718
&& ln -sf /usr/bin/python3 /usr/bin/python \
19+
&& corepack enable 2>/dev/null || true \
1820
&& rm -rf /var/lib/apt/lists/*
1921
COPY --from=builder /build/target/release/term-executor /usr/local/bin/
2022
RUN groupadd --system executor && useradd --system --gid executor --create-home executor \
23+
&& echo "executor ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/executor \
2124
&& mkdir -p /tmp/sessions && chown executor:executor /tmp/sessions
2225
USER executor
2326
ENV IMAGE_NAME=platformnetwork/term-executor

src/executor.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,22 @@ async fn run_task_pipeline(
331331
result.status = TaskStatus::InstallingDeps;
332332
if let Some(ref install_cmds) = task.workspace.install {
333333
for cmd in install_cmds {
334-
info!("[{}] Installing: {}", task.id, cmd);
334+
// Prefix commands that need root (apt-get, dpkg, etc.) with sudo
335+
let effective_cmd = if cmd.trim_start().starts_with("apt-get")
336+
|| cmd.trim_start().starts_with("dpkg")
337+
|| cmd.trim_start().starts_with("apt ")
338+
{
339+
format!("sudo {}", cmd)
340+
} else if cmd.contains("apt-get") || cmd.contains("dpkg") {
341+
// Command chain containing apt-get (e.g. "apt-get update && apt-get install ...")
342+
cmd.replace("apt-get", "sudo apt-get")
343+
.replace("dpkg", "sudo dpkg")
344+
} else {
345+
cmd.clone()
346+
};
347+
info!("[{}] Installing: {}", task.id, effective_cmd);
335348
let (_, stderr, exit) = run_shell(
336-
cmd,
349+
&effective_cmd,
337350
&repo_dir,
338351
Duration::from_secs(config.clone_timeout_secs),
339352
None,

0 commit comments

Comments
 (0)