mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-28 20:59:23 +00:00
v1.0.12 - Sveltekit migration (#44)
Changed the whole tech stack to SvelteKit which means: - Typescript - SSR - No fastify :( - Beta, but it's fine! Other changes: - Tailwind -> Tailwind JIT - A lot more
This commit is contained in:
27
src/lib/api/docker.ts
Normal file
27
src/lib/api/docker.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import Dockerode from 'dockerode';
|
||||
import { saveAppLog } from './applications/logging';
|
||||
|
||||
const { DOCKER_ENGINE, DOCKER_NETWORK } = process.env;
|
||||
export const docker = {
|
||||
engine: new Dockerode({
|
||||
socketPath: DOCKER_ENGINE
|
||||
}),
|
||||
network: DOCKER_NETWORK
|
||||
};
|
||||
export async function streamEvents(stream, configuration) {
|
||||
await new Promise((resolve, reject) => {
|
||||
docker.engine.modem.followProgress(stream, onFinished, onProgress);
|
||||
function onFinished(err, res) {
|
||||
if (err) reject(err);
|
||||
resolve(res);
|
||||
}
|
||||
function onProgress(event) {
|
||||
if (event.error) {
|
||||
saveAppLog(event.error, configuration, true);
|
||||
reject(event.error);
|
||||
} else if (event.stream) {
|
||||
saveAppLog(event.stream, configuration);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user