mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-19 14:15:21 +02:00
feat(setup): add async execution of docker pull for traefik image during setup
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
initializeNetwork,
|
||||
initializeSwarm,
|
||||
} from "@dokploy/server/setup/setup";
|
||||
import { execAsync } from "@dokploy/server";
|
||||
(async () => {
|
||||
try {
|
||||
setupDirectories();
|
||||
@@ -20,6 +21,7 @@ import {
|
||||
await initializeNetwork();
|
||||
createDefaultTraefikConfig();
|
||||
createDefaultServerTraefikConfig();
|
||||
await execAsync("docker pull traefik:v3.1.2");
|
||||
await initializeTraefik();
|
||||
await initializeRedis();
|
||||
await initializePostgres();
|
||||
|
||||
@@ -124,26 +124,6 @@ export const initializeTraefik = async ({
|
||||
console.log("No existing container to remove");
|
||||
}
|
||||
|
||||
try {
|
||||
await docker.getImage(imageName).inspect();
|
||||
console.log(`Image ${imageName} already exists locally.`);
|
||||
} catch (error: any) {
|
||||
if (error?.statusCode === 404) {
|
||||
console.log(`Image ${imageName} not found, pulling...`);
|
||||
const stream = await docker.pull(imageName);
|
||||
await new Promise((resolve, reject) => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
docker.modem.followProgress(stream, (err: Error, res: any) =>
|
||||
err ? reject(err) : resolve(res),
|
||||
);
|
||||
});
|
||||
console.log(`Image ${imageName} pulled successfully.`);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Create and start the new container
|
||||
try {
|
||||
await docker.createContainer(settings);
|
||||
|
||||
Reference in New Issue
Block a user