Skip to content

Commit b4ad151

Browse files
NathanFlurryclaude
andcommitted
feat: US-001 - Add buildImage helper to docker.ts and create SSH Dockerfile
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 096b869 commit b4ad151

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM alpine:3.19
2+
RUN apk add --no-cache openssh \
3+
&& ssh-keygen -A \
4+
&& adduser -D -s /bin/sh testuser \
5+
&& echo "testuser:testpass" | chpasswd \
6+
&& sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config \
7+
&& sed -i 's/^#PermitEmptyPasswords.*/PermitEmptyPasswords no/' /etc/ssh/sshd_config \
8+
&& mkdir -p /home/testuser/upload
9+
EXPOSE 22
10+
CMD ["/usr/sbin/sshd", "-D", "-e"]

packages/secure-exec/tests/utils/docker.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { execFileSync, execSync } from "node:child_process";
1010
import { randomBytes } from "node:crypto";
11+
import path from "node:path";
1112

1213
/* ------------------------------------------------------------------ */
1314
/* Docker availability check */
@@ -74,6 +75,20 @@ export interface Container {
7475
/* Core implementation */
7576
/* ------------------------------------------------------------------ */
7677

78+
/**
79+
* Build a Docker image from a Dockerfile and tag it.
80+
*/
81+
export function buildImage(dockerfilePath: string, tag: string): void {
82+
if (!isDockerAvailable()) {
83+
throw new Error("Docker is not available on this host");
84+
}
85+
execFileSync(
86+
"docker",
87+
["build", "-t", tag, "-f", dockerfilePath, path.dirname(dockerfilePath)],
88+
{ stdio: "ignore", timeout: 120_000 },
89+
);
90+
}
91+
7792
/**
7893
* Pull an image if it is not already present locally.
7994
*/

0 commit comments

Comments
 (0)