Skip to content
Merged
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
26 changes: 26 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,32 @@ app.post('/stop/:option', async (req: Request, res: Response) => {
}
});

app.put('/pull/:image', async (req: Request, res: Response) => {
Comment thread
ConnorNeed marked this conversation as resolved.
try {
const image = req.params.image;
Comment thread
ConnorNeed marked this conversation as resolved.

Comment thread
ConnorNeed marked this conversation as resolved.
const result = await new Promise((resolve, reject) => {
docker.pull(image, (err: any, stream: NodeJS.ReadableStream) => {
if (err) return reject(err);

docker.modem.followProgress(
stream,
(err: any, output: any) => {
if (err) return reject(err);
resolve(output);
}
);
});
});

res.json({ status: 'Image pulled successfully', result });

} catch (err: any) {
console.error("Pull error:", err);
res.status(500).json({ error: err.message });
Comment thread
ConnorNeed marked this conversation as resolved.
Comment thread
ConnorNeed marked this conversation as resolved.
}
});

(async () => {
const eventStream = await docker.getEvents();
eventStream.on('data', buffer => {
Expand Down
Loading