Skip to content

Commit 7eb85f3

Browse files
authored
Merge pull request #3 from webteractive/fix-docker-compose-commands
Fix docker compose commands
2 parents ba00fb8 + 69f5d54 commit 7eb85f3

File tree

13 files changed

+89
-38
lines changed

13 files changed

+89
-38
lines changed

devstack

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,30 @@ if (file_exists($autoload = __DIR__ . '/vendor/autoload.php')) {
88
}
99

1010
use Webteractive\Devstack\App;
11-
use Webteractive\Devstack\Commands\MySql;
11+
use Webteractive\Devstack\Commands\Wp;
12+
use Webteractive\Devstack\Commands\Php;
13+
use Webteractive\Devstack\Commands\Init;
1214
use Webteractive\Devstack\Commands\Redis;
15+
use Webteractive\Devstack\Commands\MySql;
1316
use Webteractive\Devstack\Commands\Shell;
1417
use Webteractive\Devstack\Commands\Config;
15-
use Webteractive\Devstack\Commands\InitStack;
16-
use Webteractive\Devstack\Commands\RunPhpCommand;
17-
use Webteractive\Devstack\Commands\DownloadRuntimes;
18-
use Webteractive\Devstack\Commands\RunComposerCommands;
18+
use Webteractive\Devstack\Commands\Artisan;
19+
use Webteractive\Devstack\Commands\Download;
20+
use Webteractive\Devstack\Commands\Composer;
1921
use Webteractive\Devstack\RegisterDockerComposeCommands;
20-
use Webteractive\Devstack\Commands\RunLaravelArtisanCommand;
2122

22-
$app = new App('Devstack', '1.1.7');
23+
$app = new App('Devstack', '1.1.8');
2324

24-
$app->add(new InitStack);
25+
$app->add(new Init);
2526
$app->add(new Config);
26-
$app->add(new DownloadRuntimes);
27-
$app->add(new RunLaravelArtisanCommand);
28-
$app->add(new RunPhpCommand);
29-
$app->add(new RunComposerCommands);
27+
$app->add(new Download);
28+
$app->add(new Artisan);
29+
$app->add(new Php);
30+
$app->add(new Composer);
3031
$app->add(new Shell);
3132
$app->add(new MySql);
3233
$app->add(new Redis);
34+
$app->add(new Wp);
3335

3436
RegisterDockerComposeCommands::register($app);
3537

src/Commands/RunLaravelArtisanCommand.php renamed to src/Commands/Artisan.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use Webteractive\Devstack\Process;
66
use Webteractive\Devstack\WithSignalHandlers;
77

8-
class RunLaravelArtisanCommand extends Base
8+
class Artisan extends Base
99
{
1010
use WithSignalHandlers;
1111

1212
protected $signature = 'artisan';
13-
protected $description = 'Run Laravel\'s artisan command.';
13+
protected $description = 'Run <info>Laravel\'s artisan</info> command within the <info>app</info> container.';
1414

1515
public function shouldIgnoreValidationErrors(): bool
1616
{
@@ -35,7 +35,9 @@ public function handle(): int
3535
$process = Process::prepare(array_merge($command, $this->fullCommandSignature))
3636
);
3737

38-
$process->setTty(true)->run();
38+
$process->setTimeout(null)
39+
->setTty(true)
40+
->run();
3941

4042
return static::SUCCESS;
4143
}

src/Commands/RunComposerCommands.php renamed to src/Commands/Composer.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use Webteractive\Devstack\Process;
66
use Webteractive\Devstack\WithSignalHandlers;
77

8-
class RunComposerCommands extends Base
8+
class Composer extends Base
99
{
1010
use WithSignalHandlers;
1111

1212
protected $signature = 'composer';
13-
protected $description = 'Run composer commands.';
13+
protected $description = 'Run <info>composer</info> commands within the <info>app</info> container.';
1414

1515
public function shouldIgnoreValidationErrors(): bool
1616
{
@@ -35,7 +35,9 @@ public function handle(): int
3535
$process = Process::prepare(array_merge($command, $this->fullCommandSignature))
3636
);
3737

38-
$process->setTty(true)->run();
38+
$process->setTimeout(null)
39+
->setTty(true)
40+
->run();
3941

4042
return static::SUCCESS;
4143
}

src/Commands/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Config extends Base
99
use ShouldConfigure;
1010

1111
protected $signature = 'config';
12-
protected $description = 'Configure Devstack runtime settings';
12+
protected $description = 'Configure private devstack runtime settings.';
1313

1414
public function handle(): int
1515
{

src/Commands/RunDockerCommands.php renamed to src/Commands/DockerCompose.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
namespace Webteractive\Devstack\Commands;
44

55
use Webteractive\Devstack\Process;
6+
use Symfony\Component\Process\Process as SymfonyProcess;
67
use Webteractive\Devstack\WithSignalHandlers;
78

8-
class RunDockerCommands extends Base
9+
class DockerCompose extends Base
910
{
1011
use WithSignalHandlers;
1112

@@ -30,7 +31,9 @@ public function handle(): int
3031
$process = Process::prepare($commandSignature)
3132
);
3233

33-
$process->setTty(true)->run();
34+
$process->setTimeout(null)
35+
->setTty(true)
36+
->run();
3437

3538
return static::SUCCESS;
3639
}

src/Commands/DownloadRuntimes.php renamed to src/Commands/Download.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use Webteractive\Devstack\ShouldConfigure;
66
use Webteractive\Devstack\RuntimeDownloader;
77

8-
class DownloadRuntimes extends Base
8+
class Download extends Base
99
{
1010
use ShouldConfigure;
1111

1212
protected $signature = 'download';
13-
protected $description = 'Download latest runtimes';
13+
protected $description = 'Download latest private runtimes.';
1414

1515
public function handle(): int
1616
{

src/Commands/InitStack.php renamed to src/Commands/Init.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Webteractive\Devstack\RuntimeDownloader;
88
use Webteractive\Devstack\PublicRuntimeDownloader;
99

10-
class InitStack extends Base
10+
class Init extends Base
1111
{
1212
use ShouldConfigure;
1313

src/Commands/MySql.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MySql extends Base
1515
{--u|user= : The user to use.}
1616
{--db|database= : The database to use.}
1717
{--env= : The path to the .env file. Default\'s to the current working directory.}';
18-
protected $description = 'Start a MySQL CLI session within the <comment>mysql</comment> container.';
18+
protected $description = 'Start a <info>MySQL CLI</info> session within the <info>mysql</info> container.';
1919

2020
public function handle(): int
2121
{
@@ -70,8 +70,7 @@ public function handle(): int
7070
);
7171

7272
$process->setTty(true)
73-
->setTimeout(60 * 60 * 2)
74-
->setIdleTimeout(60 * 60 * 8)
73+
->setTimeout(null)
7574
->run();
7675

7776
return static::SUCCESS;

src/Commands/RunPhpCommand.php renamed to src/Commands/Php.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use Webteractive\Devstack\Process;
66
use Webteractive\Devstack\WithSignalHandlers;
77

8-
class RunPhpCommand extends Base
8+
class Php extends Base
99
{
1010
use WithSignalHandlers;
1111

1212
protected $signature = 'php';
13-
protected $description = 'Run PHP commands.';
13+
protected $description = 'Run <info>PHP</info> CLI within the <info>app</info> container.';
1414

1515
public function shouldIgnoreValidationErrors(): bool
1616
{
@@ -34,7 +34,9 @@ public function handle(): int
3434
$process = Process::prepare(array_merge($command, $this->fullCommandSignature))
3535
);
3636

37-
$process->setTty(true)->run();
37+
$process->setTimeout(null)
38+
->setTty(true)
39+
->run();
3840

3941
return static::SUCCESS;
4042
}

src/Commands/Redis.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Redis extends Base
1010
use WithSignalHandlers;
1111

1212
protected $signature = 'redis';
13-
protected $description = 'Start a Redis CLI session within the <comment>redis</comment> container.';
13+
protected $description = 'Start a <info>Redis CLI</info> session within the <info>redis</info> container.';
1414

1515
public function handle(): int
1616
{
@@ -20,8 +20,7 @@ public function handle(): int
2020
);
2121

2222
$process->setTty(true)
23-
->setTimeout(60 * 60 * 2)
24-
->setIdleTimeout(60 * 60 * 8)
23+
->setTimeout(null)
2524
->run();
2625

2726
return static::SUCCESS;

src/Commands/Shell.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Shell extends Base
1010
use WithSignalHandlers;
1111

1212
protected $signature = 'shell {--r|root : As a root user.}';
13-
protected $description = 'Start a shell session within the application container';
13+
protected $description = 'Start a shell session within the <info>app</info> container.';
1414

1515
public function handle(): int
1616
{
@@ -30,8 +30,7 @@ public function handle(): int
3030
);
3131

3232
$process->setTty(true)
33-
->setTimeout(60 * 60 * 2)
34-
->setIdleTimeout(60 * 60 * 8)
33+
->setTimeout(null)
3534
->run();
3635

3736
return static::SUCCESS;

src/Commands/Wp.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Webteractive\Devstack\Commands;
4+
5+
use Webteractive\Devstack\Process;
6+
use Webteractive\Devstack\WithSignalHandlers;
7+
8+
class Wp extends Base
9+
{
10+
use WithSignalHandlers;
11+
12+
protected $signature = 'wp';
13+
protected $description = 'Run <info>WordPress CLI</info> commands within the <info>app</info> container.';
14+
15+
public function shouldIgnoreValidationErrors(): bool
16+
{
17+
return true;
18+
}
19+
20+
public function handle(): int
21+
{
22+
$command = [
23+
'docker',
24+
'compose',
25+
'exec',
26+
'-u',
27+
'dev',
28+
'-T',
29+
'app',
30+
'wp',
31+
];
32+
33+
$this->handleTerminationSignals(
34+
$process = Process::prepare(array_merge($command, $this->fullCommandSignature))
35+
);
36+
37+
$process->setTimeout(null)
38+
->setTty(true)
39+
->run();
40+
41+
return static::SUCCESS;
42+
}
43+
}

src/RegisterDockerComposeCommands.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Webteractive\Devstack;
44

55
use Symfony\Component\Console\Application;
6-
use Webteractive\Devstack\Commands\RunDockerCommands;
6+
use Webteractive\Devstack\Commands\DockerCompose;
77

88
class RegisterDockerComposeCommands
99
{
@@ -38,7 +38,7 @@ class RegisterDockerComposeCommands
3838
public static function register(Application $app, $prefix = 'runtime')
3939
{
4040
foreach (static::$commands as $name => $description) {
41-
$app->add(new RunDockerCommands($name, $description));
41+
$app->add(new DockerCompose($name, '<comment>[Docker Compose]</comment> ' . $description));
4242
}
4343
}
4444
}

0 commit comments

Comments
 (0)