Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ RUN mkdir -p /workspace/group /workspace/global /workspace/extra /workspace/ipc/

# Create entrypoint script
# Container input (prompt, group info) is passed via stdin JSON.
# Capture stdin before any startup work so BoxLite input cannot be lost while
# the runner is recompiled from the mounted /app/src tree.
# Credentials are injected by the host's credential proxy — never passed here.
# Follow-up messages arrive via IPC files in /workspace/ipc/input/
RUN printf '#!/bin/bash\nset -e\ncd /app && npx tsc --outDir /tmp/dist 2>&1 >&2\nln -s /app/node_modules /tmp/dist/node_modules\nchmod -R a-w /tmp/dist\ncat > /tmp/input.json\nnode /tmp/dist/index.js < /tmp/input.json\n' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
RUN printf '#!/bin/bash\nset -e\ncat > /tmp/input.json\ncd /app && npx tsc --outDir /tmp/dist 2>&1 >&2\nln -s /app/node_modules /tmp/dist/node_modules\nchmod -R a-w /tmp/dist\nnode /tmp/dist/index.js < /tmp/input.json\n' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh

# Set ownership to node user (non-root) for writable directories
RUN chown -R node:node /workspace && chmod 777 /home/node
Expand Down
18 changes: 18 additions & 0 deletions src/container-image.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import fs from 'fs';
import path from 'path';

import { describe, expect, it } from 'vitest';

describe('container entrypoint', () => {
it('captures stdin before recompiling the runner', () => {
const dockerfilePath = path.join(process.cwd(), 'container', 'Dockerfile');
const dockerfile = fs.readFileSync(dockerfilePath, 'utf-8');

const captureIdx = dockerfile.indexOf('cat > /tmp/input.json');
const compileIdx = dockerfile.indexOf('npx tsc --outDir /tmp/dist');

expect(captureIdx).toBeGreaterThanOrEqual(0);
expect(compileIdx).toBeGreaterThanOrEqual(0);
expect(captureIdx).toBeLessThan(compileIdx);
});
});
Loading