mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-18 01:45:17 +00: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,
|
initializeNetwork,
|
||||||
initializeSwarm,
|
initializeSwarm,
|
||||||
} from "@dokploy/server/setup/setup";
|
} from "@dokploy/server/setup/setup";
|
||||||
|
import { execAsync } from "@dokploy/server";
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
setupDirectories();
|
setupDirectories();
|
||||||
@@ -20,6 +21,7 @@ import {
|
|||||||
await initializeNetwork();
|
await initializeNetwork();
|
||||||
createDefaultTraefikConfig();
|
createDefaultTraefikConfig();
|
||||||
createDefaultServerTraefikConfig();
|
createDefaultServerTraefikConfig();
|
||||||
|
await execAsync("docker pull traefik:v3.1.2");
|
||||||
await initializeTraefik();
|
await initializeTraefik();
|
||||||
await initializeRedis();
|
await initializeRedis();
|
||||||
await initializePostgres();
|
await initializePostgres();
|
||||||
|
|||||||
@@ -124,26 +124,6 @@ export const initializeTraefik = async ({
|
|||||||
console.log("No existing container to remove");
|
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
|
// Create and start the new container
|
||||||
try {
|
try {
|
||||||
await docker.createContainer(settings);
|
await docker.createContainer(settings);
|
||||||
|
|||||||
Reference in New Issue
Block a user