File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -342,6 +342,8 @@ export const readPorts = async (
342
342
command = `docker service inspect ${ resourceName } --format '{{json .Spec.EndpointSpec.Ports}}'` ;
343
343
} else if ( resourceType === "standalone" ) {
344
344
command = `docker container inspect ${ resourceName } --format '{{json .NetworkSettings.Ports}}'` ;
345
+ } else {
346
+ throw new Error ( "Resource type not found" ) ;
345
347
}
346
348
let result = "" ;
347
349
if ( serverId ) {
@@ -397,17 +399,20 @@ export const writeTraefikSetup = async (input: TraefikOptions) => {
397
399
"dokploy-traefik" ,
398
400
input . serverId ,
399
401
) ;
402
+
400
403
if ( resourceType === "service" ) {
401
404
await initializeTraefikService ( {
402
405
env : input . env ,
403
406
additionalPorts : input . additionalPorts ,
404
407
serverId : input . serverId ,
405
408
} ) ;
406
- } else {
409
+ } else if ( resourceType === "standalone" ) {
407
410
await initializeStandaloneTraefik ( {
408
411
env : input . env ,
409
412
additionalPorts : input . additionalPorts ,
410
413
serverId : input . serverId ,
411
414
} ) ;
415
+ } else {
416
+ throw new Error ( "Traefik resource type not found" ) ;
412
417
}
413
418
} ;
Original file line number Diff line number Diff line change @@ -87,16 +87,27 @@ export const initializeStandaloneTraefik = async ({
87
87
} ;
88
88
89
89
const docker = await getRemoteDocker ( serverId ) ;
90
+ try {
91
+ await docker . pull ( imageName ) ;
92
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) ) ;
93
+ console . log ( "Traefik Image Pulled ✅" ) ;
94
+ } catch ( error ) {
95
+ console . log ( "Traefik Image Not Found: Pulling " , error ) ;
96
+ }
90
97
try {
91
98
const container = docker . getContainer ( containerName ) ;
92
99
await container . remove ( { force : true } ) ;
93
100
await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) ) ;
94
101
} catch { }
95
102
96
- await docker . createContainer ( settings ) ;
97
- const newContainer = docker . getContainer ( containerName ) ;
98
- await newContainer . start ( ) ;
99
- console . log ( "Traefik Started ✅" ) ;
103
+ try {
104
+ await docker . createContainer ( settings ) ;
105
+ const newContainer = docker . getContainer ( containerName ) ;
106
+ await newContainer . start ( ) ;
107
+ console . log ( "Traefik Started ✅" ) ;
108
+ } catch ( error ) {
109
+ console . log ( "Traefik Not Found: Starting " , error ) ;
110
+ }
100
111
} ;
101
112
102
113
export const initializeTraefikService = async ( {
You can’t perform that action at this time.
0 commit comments