11import { ContainerInfo } from "dockerode" ;
22import { containerLog , log , RandomUuid , Uuid } from "../common" ;
3- import { getContainerRuntimeClient , parseComposeContainerName } from "../container-runtime" ;
3+ import { ComposeOptions , getContainerRuntimeClient , parseComposeContainerName } from "../container-runtime" ;
44import { StartedGenericContainer } from "../generic-container/started-generic-container" ;
55import { getReaper } from "../reaper/reaper" ;
66import { Environment } from "../types" ;
@@ -26,6 +26,7 @@ export class DockerComposeEnvironment {
2626 private defaultWaitStrategy : WaitStrategy = Wait . forListeningPorts ( ) ;
2727 private waitStrategy : { [ containerName : string ] : WaitStrategy } = { } ;
2828 private startupTimeoutMs ?: number ;
29+ private clientOptions : Partial < ComposeOptions > = { } ;
2930
3031 constructor ( composeFilePath : string , composeFiles : string | string [ ] , uuid : Uuid = new RandomUuid ( ) ) {
3132 this . composeFilePath = composeFilePath ;
@@ -84,27 +85,41 @@ export class DockerComposeEnvironment {
8485 return this ;
8586 }
8687
88+ public withClientOptions (
89+ options : Partial < Omit < ComposeOptions , "filePath" | "files" | "projectName" | "environment" > >
90+ ) : this {
91+ this . clientOptions = { ...this . clientOptions , ...options } ;
92+ return this ;
93+ }
94+
8795 public async up ( services ?: Array < string > ) : Promise < StartedDockerComposeEnvironment > {
8896 log . info ( `Starting DockerCompose environment "${ this . projectName } "...` ) ;
8997 const client = await getContainerRuntimeClient ( ) ;
9098 const reaper = await getReaper ( client ) ;
9199 reaper . addComposeProject ( this . projectName ) ;
92100
101+ const {
102+ composeOptions : clientComposeOptions = [ ] ,
103+ commandOptions : clientCommandOptions = [ ] ,
104+ ...remainingClientOptions
105+ } = this . clientOptions ;
106+
93107 const options = {
108+ ...remainingClientOptions ,
94109 filePath : this . composeFilePath ,
95110 files : this . composeFiles ,
96111 projectName : this . projectName ,
97112 } ;
98113
99- const commandOptions = [ ] ;
114+ const commandOptions = [ ... clientCommandOptions ] ;
100115 if ( this . build ) {
101116 commandOptions . push ( "--build" ) ;
102117 }
103118 if ( ! this . recreate ) {
104119 commandOptions . push ( "--no-recreate" ) ;
105120 }
106121
107- const composeOptions : string [ ] = [ ] ;
122+ const composeOptions = [ ... clientComposeOptions ] ;
108123 if ( this . environmentFile ) {
109124 composeOptions . push ( "--env-file" , this . environmentFile ) ;
110125 }
0 commit comments