Skip to content

Commit 88c089d

Browse files
authored
fix(relay): include git hook tools in runtime image (#1326)
Signed-off-by: Thomas Petersen <[email protected]>
1 parent c88799a commit 88c089d

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎Dockerfile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ LABEL org.opencontainers.image.title="Buzz" \
7777
RUN apt-get update \
7878
&& apt-get install -y --no-install-recommends \
7979
ca-certificates \
80+
curl \
8081
git \
82+
openssl \
8183
&& rm -rf /var/lib/apt/lists/* \
8284
&& groupadd --system --gid 1000 buzz \
8385
&& useradd --system --uid 1000 --gid 1000 --home-dir /var/lib/buzz \

‎crates/buzz-relay/src/api/git/hook.rs‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,32 @@ pub async fn install_hook(repo_path: &Path) -> anyhow::Result<()> {
176176
info!(repo = %repo_path.display(), "pre-receive hook installed");
177177
Ok(())
178178
}
179+
180+
#[cfg(test)]
181+
mod tests {
182+
use super::PRE_RECEIVE_HOOK;
183+
184+
#[test]
185+
fn runtime_image_installs_pre_receive_hook_tools() {
186+
let dockerfile = include_str!("../../../../../Dockerfile");
187+
let runtime_stage = dockerfile
188+
.split("FROM debian:${DEBIAN_VERSION}-slim AS runtime")
189+
.nth(1)
190+
.expect("Dockerfile should have a runtime stage");
191+
let runtime_setup = runtime_stage
192+
.split("COPY --from=builder")
193+
.next()
194+
.expect("runtime stage should copy built artifacts after package setup");
195+
196+
for tool in ["curl", "openssl"] {
197+
assert!(
198+
PRE_RECEIVE_HOOK.contains(tool),
199+
"test setup expected the pre-receive hook to invoke {tool}"
200+
);
201+
assert!(
202+
runtime_setup.contains(&format!("\n {tool} \\")),
203+
"relay runtime image must install {tool}; the git pre-receive hook uses it and fails closed without it"
204+
);
205+
}
206+
}
207+
}

0 commit comments

Comments
 (0)