Skip to content

Commit 14983f9

Browse files
committed
Make docker functions more generic
1 parent 1f547cd commit 14983f9

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

php/class-ee-docker.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,21 @@ public static function disconnect_site_network_from( $site_name, $from_container
152152
/**
153153
* Function to boot the containers.
154154
*
155-
* @param String $dir Path to docker-compose.yml.
155+
* @param String $dir Path to docker-compose.yml.
156+
* @param array $services Services to bring up.
156157
*
157158
* @return bool success.
158159
*/
159-
public static function docker_compose_up( $dir ) {
160+
public static function docker_compose_up( $dir, $services = [] ) {
160161
$chdir_return_code = chdir( $dir );
161162
if ( $chdir_return_code ) {
162-
return default_launch( 'docker-compose up -d' );
163+
if ( empty( $services ) ) {
164+
return default_launch( 'docker-compose up -d' );
165+
} else {
166+
$all_services = implode( ' ', $services );
167+
168+
return default_launch( "docker-compose up -d $all_services" );
169+
}
163170
}
164171

165172
return false;
@@ -168,14 +175,21 @@ public static function docker_compose_up( $dir ) {
168175
/**
169176
* Function to destroy the containers.
170177
*
171-
* @param String $dir Path to docker-compose.yml.
178+
* @param String $dir Path to docker-compose.yml.
179+
* @param array $services Services to bring up.
172180
*
173181
* @return bool success.
174182
*/
175-
public static function docker_compose_down( $dir ) {
183+
public static function docker_compose_down( $dir, $services = [] ) {
176184
$chdir_return_code = chdir( $dir );
177185
if ( $chdir_return_code ) {
178-
return default_launch( 'docker-compose down' );
186+
if ( empty( $services ) ) {
187+
return default_launch( 'docker-compose up -d' );
188+
} else {
189+
$all_services = implode( ' ', $services );
190+
191+
return default_launch( "docker-compose up $all_services -d" );
192+
}
179193
}
180194

181195
return false;

0 commit comments

Comments
 (0)