Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 44 additions & 25 deletions inc/composer/class-docker-compose-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,40 @@
return $services;
}

/**

Check failure on line 228 in inc/composer/class-docker-compose-generator.php

View check run for this annotation

HM Linter / hmlinter

inc/composer/class-docker-compose-generator.php#L228

Doc comment for parameter "$args" missing
Raw output
{
  "line": 228,
  "column": 5,
  "severity": "error",
  "message": "Doc comment for parameter \"$args\" missing",
  "source": "Squiz.Commenting.FunctionComment.MissingParamTag"
}
* Default memory limit for all services that don't specify one.
*
* @param $args

Check failure on line 231 in inc/composer/class-docker-compose-generator.php

View check run for this annotation

HM Linter / hmlinter

inc/composer/class-docker-compose-generator.php#L231

Missing parameter name
Raw output
{
  "line": 231,
  "column": 8,
  "severity": "error",
  "message": "Missing parameter name",
  "source": "Squiz.Commenting.FunctionComment.MissingParamName"
}
*
* @return array
*/
protected function apply_service_defaults( $args ) : array {
$mem_limit = getenv( 'LS_MEM_LIMIT' ) ?: '1g';
foreach ( $args as $service => $service_args ) {
if ( isset( $service_args['mem_limit'] ) ) {
continue;
}
$args[ $service ]['mem_limit'] = $mem_limit;
}

return $args;
}

Check failure on line 246 in inc/composer/class-docker-compose-generator.php

View check run for this annotation

HM Linter / hmlinter

inc/composer/class-docker-compose-generator.php#L246

Multiple empty lines should not exist in a row; found 2 consecutive empty lines
Raw output
{
  "line": 246,
  "column": 1,
  "severity": "error",
  "message": "Multiple empty lines should not exist in a row; found 2 consecutive empty lines",
  "source": "HM.Whitespace.MultipleEmptyLines.MultipleEmptyLines"
}

/**
* Get the PHP container service.
*
* @return array
*/
protected function get_service_php() : array {
return [
return $this->apply_service_defaults( [
'php' => array_merge(
[
'container_name' => "{$this->project_name}-php",
],
$this->get_php_reusable()
),
];
] );
}

/**
Expand All @@ -253,7 +273,7 @@
$package_json = json_decode( file_get_contents( "{$config['nodejs']['path']}/package.json" ), true );
$version = $package_json['engines']['node'] ?? '20';

return [
return $this->apply_service_defaults( [
'nodejs' => [
'image' => "node:{$version}-bookworm-slim",
'container_name' => "{$this->project_name}-nodejs",
Expand Down Expand Up @@ -282,7 +302,7 @@
'ALTIS_ENVIRONMENT_TYPE' => 'local',
],
],
];
] );
}

/**
Expand All @@ -291,7 +311,7 @@
* @return array
*/
protected function get_service_webgrind() : array {
return [
return $this->apply_service_defaults( [
'webgrind' => [
'container_name' => "{$this->project_name}-webgrind",
'image' => 'wodby/webgrind:1.9',
Expand All @@ -318,7 +338,7 @@
'WEBGRIND_DEFAULT_TIMEZONE' => 'UTC',
],
],
];
] );
}

/**
Expand All @@ -327,7 +347,7 @@
* @return array
*/
protected function get_service_cavalcade() : array {
return [
return $this->apply_service_defaults( [
'cavalcade' => array_merge(
[
'container_name' => "{$this->project_name}-cavalcade",
Expand All @@ -339,7 +359,7 @@
],
$this->get_php_reusable()
),
];
] );
}

/**
Expand All @@ -352,7 +372,7 @@
$domains = $config['domains'] ?? [];
$domains = $domains ? ',' . implode( ',', $domains ) : '';

return [
return $this->apply_service_defaults( [
'nginx' => [
'image' => 'humanmade/altis-local-server-nginx:3.6.0',
'container_name' => "{$this->project_name}-nginx",
Expand Down Expand Up @@ -387,7 +407,7 @@
'PHP_PUBLIC_POOL_ENABLE_RATE_LIMIT' => 'false',
],
],
];
] );
}

/**
Expand All @@ -396,15 +416,15 @@
* @return array
*/
protected function get_service_redis() : array {
return [
return $this->apply_service_defaults( [
'redis' => [
'image' => 'redis:7.0-alpine',
'container_name' => "{$this->project_name}-redis",
'ports' => [
'6379',
],
],
];
] );
}

/**
Expand Down Expand Up @@ -433,7 +453,7 @@

$image = $version_map[ $version ];

return [
return $this->apply_service_defaults( [
'db' => [
'image' => $image,
// Suppress mysql_native_password deprecation warning
Expand Down Expand Up @@ -468,7 +488,7 @@
'retries' => 10,
],
],
];
] );
}

/**
Expand All @@ -477,7 +497,7 @@
* @return array
*/
protected function get_service_s3() : array {
return [
return $this->apply_service_defaults( [
's3' => [
'image' => 'minio/minio:RELEASE.2021-09-18T18-09-59Z',
'container_name' => "{$this->project_name}-s3",
Expand Down Expand Up @@ -560,7 +580,7 @@
],
'entrypoint' => "/bin/sh -c \"mc mirror --watch --overwrite -a local/{$this->bucket_name} /content\"",
],
];
] );
}

/**
Expand All @@ -569,7 +589,7 @@
* @return array
*/
protected function get_service_tachyon() : array {
return [
return $this->apply_service_defaults( [
'tachyon' => [
'image' => 'humanmade/tachyon:v3.0.7',
'container_name' => "{$this->project_name}-tachyon",
Expand All @@ -596,7 +616,7 @@
"proxy:s3-{$this->hostname}",
],
],
];
] );
}

/**
Expand All @@ -605,7 +625,7 @@
* @return array
*/
protected function get_service_mailhog() : array {
return [
return $this->apply_service_defaults( [
'mailhog' => [
'image' => 'cd2team/mailhog:latest',
'container_name' => "{$this->project_name}-mailhog",
Expand All @@ -627,7 +647,7 @@
'MH_UI_WEB_PATH' => 'mailhog',
],
],
];
] );
}

/**
Expand All @@ -636,7 +656,7 @@
* @return array
*/
protected function get_service_analytics() : array {
return [
return $this->apply_service_defaults( [
'cognito' => [
'container_name' => "{$this->project_name}-cognito",
'ports' => [
Expand Down Expand Up @@ -678,7 +698,7 @@
'INDEX_ROTATION' => 'OneDay',
],
],
];
] );
}

/**
Expand All @@ -687,7 +707,7 @@
* @return array
*/
protected function get_service_xray() : array {
return [
return $this->apply_service_defaults( [
'xray' => [
'image' => 'amazon/aws-xray-daemon:3.3.3',
'container_name' => "{$this->project_name}-xray",
Expand All @@ -700,7 +720,7 @@
'AWS_REGION' => 'us-east-1',
],
],
];
] );
}

/**
Expand Down Expand Up @@ -751,7 +771,6 @@

// Default compose configuration.
$config = [
// 'version' => '2.5',
'services' => $services,
'networks' => [
'default' => null,
Expand Down
Loading