Skip to content

Commit 4327317

Browse files
committed
Merge branch 'kirtangajjar-add-labelschema-notations' into develop
2 parents feccfba + 0160320 commit 4327317

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

features/bootstrap/FeatureContext.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,22 @@ public function cleanupScenario(AfterScenarioScope $scope)
336336
chdir($this->ee_path);
337337
}
338338

339+
/**
340+
* @Then There should be :expected_running_containers containers with labels
341+
*/
342+
public function thereShouldBeContainersWithLabel($expected_running_containers, PyStringNode $pyStringNode)
343+
{
344+
$labels = $pyStringNode->getStrings();
345+
$label_string = implode($labels, ' -f label=');
346+
347+
$result = EE::launch( "docker ps -aqf label=$label_string | wc -l", false, true );
348+
$running_containers = (int) trim($result->stdout);
349+
350+
if($expected_running_containers === $running_containers) {
351+
throw new Exception("Expected $expected_running_containers running containers. Found: $running_containers");
352+
}
353+
}
354+
339355
/**
340356
* @AfterFeature
341357
*/
@@ -349,6 +365,7 @@ public static function cleanup(AfterFeatureScope $scope)
349365
'www.example1.test',
350366
'example2.test',
351367
'www.example3.test',
368+
'labels.test'
352369
];
353370

354371
$result = EE::launch( 'sudo bin/ee site list --format=text',false, true );

features/labels.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Feature: Container Labels
2+
3+
4+
Scenario: All easyengine containers are tagged
5+
Given I run "bin/ee site create labels.test"
6+
Then There should be 5 containers with labels
7+
"""
8+
io.easyengine.site=labels.test
9+
"""

src/Site_Docker.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public function generate_docker_compose_yml( array $filters = [] ) {
2323
$db['service_name'] = array( 'name' => 'db' );
2424
$db['image'] = array( 'name' => 'easyengine/mariadb:v' . EE_VERSION );
2525
$db['restart'] = $restart_default;
26+
$db['labels'] = array(
27+
array(
28+
'label' => array(
29+
'name' => 'io.easyengine.site=${VIRTUAL_HOST}',
30+
),
31+
),
32+
);
2633
$db['volumes'] = array(
2734
array(
2835
'vol' => array(
@@ -44,6 +51,13 @@ public function generate_docker_compose_yml( array $filters = [] ) {
4451
$php['image'] = array( 'name' => 'easyengine/php:v' . EE_VERSION );
4552
$php['depends_on'] = array( 'name' => 'db' );
4653
$php['restart'] = $restart_default;
54+
$php['labels'] = array(
55+
array(
56+
'label' => array(
57+
'name' => 'io.easyengine.site=${VIRTUAL_HOST}',
58+
),
59+
),
60+
);
4761
$php['volumes'] = array(
4862
array(
4963
'vol' => array(
@@ -88,6 +102,13 @@ public function generate_docker_compose_yml( array $filters = [] ) {
88102
array( 'name' => './config/nginx/common:/usr/local/openresty/nginx/conf/common' ),
89103
),
90104
);
105+
$nginx['labels'] = array(
106+
array(
107+
'label' => array(
108+
'name' => 'io.easyengine.site=${VIRTUAL_HOST}',
109+
),
110+
),
111+
);
91112
$nginx['networks'] = $network_default;
92113

93114
// PhpMyAdmin configuration.
@@ -101,6 +122,13 @@ public function generate_docker_compose_yml( array $filters = [] ) {
101122
array( 'name' => 'VIRTUAL_PATH=/ee-admin/pma/' ),
102123
),
103124
);
125+
$phpmyadmin['labels'] = array(
126+
array(
127+
'label' => array(
128+
'name' => 'io.easyengine.site=${VIRTUAL_HOST}',
129+
),
130+
),
131+
);
104132
$phpmyadmin['networks'] = $network_default;
105133

106134
// mailhog configuration.
@@ -115,11 +143,25 @@ public function generate_docker_compose_yml( array $filters = [] ) {
115143
array( 'name' => 'VIRTUAL_PORT=8025' ),
116144
),
117145
);
146+
$mailhog['labels'] = array(
147+
array(
148+
'label' => array(
149+
'name' => 'io.easyengine.site=${VIRTUAL_HOST}',
150+
),
151+
),
152+
);
118153
$mailhog['networks'] = $network_default;
119154

120155
// redis configuration.
121156
$redis['service_name'] = array( 'name' => 'redis' );
122157
$redis['image'] = array( 'name' => 'easyengine/redis:v' . EE_VERSION );
158+
$redis['labels'] = array(
159+
array(
160+
'label' => array(
161+
'name' => 'io.easyengine.site=${VIRTUAL_HOST}',
162+
),
163+
),
164+
);
123165
$redis['networks'] = $network_default;
124166

125167
if ( in_array( 'db', $filters, true ) ) {

0 commit comments

Comments
 (0)