mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-22 07:30:25 +00:00
update
This commit is contained in:
parent
68986ed943
commit
f929f007dd
4 changed files with 15 additions and 8 deletions
|
@ -89,7 +89,6 @@ class DockerContainer extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
$createContainer = $dockerContainerApi->run();
|
$createContainer = $dockerContainerApi->run();
|
||||||
|
|
||||||
if (!isset($createContainer['ID'])) {
|
if (!isset($createContainer['ID'])) {
|
||||||
throw new \Exception('Failed to create container');
|
throw new \Exception('Failed to create container');
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ class DockerContainerApi
|
||||||
'externalPort' => $this->externalPort,
|
'externalPort' => $this->externalPort,
|
||||||
'environmentVariables' => $this->environmentVariables,
|
'environmentVariables' => $this->environmentVariables,
|
||||||
'volumeMapping' => $this->volumeMapping,
|
'volumeMapping' => $this->volumeMapping,
|
||||||
|
'version' => '3'
|
||||||
])->render();
|
])->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ class DockerContainerApi
|
||||||
shell_exec('mkdir -p ' . $dockerContaienrPath);
|
shell_exec('mkdir -p ' . $dockerContaienrPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$dockerComposeFile = $dockerContaienrPath . '/docker-compose.yml';
|
$dockerComposeFile = $dockerContaienrPath . '/docker-compose.yml';
|
||||||
file_put_contents($dockerComposeFile, $dockerComposeFileContent);
|
file_put_contents($dockerComposeFile, $dockerComposeFileContent);
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,14 @@ version: '{{$version}}'
|
||||||
services:
|
services:
|
||||||
|
|
||||||
{{$name}}:
|
{{$name}}:
|
||||||
image: {{$image}}
|
image: "{{$image}}"
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- {{$externalPort}}:{{ $port }}
|
- {{$externalPort}}:{{ $port }}
|
||||||
|
|
||||||
@if(isset($environmentVariables) && !empty($environmentVariables))
|
@if(isset($environmentVariables)
|
||||||
|
&& !empty($environmentVariables)
|
||||||
|
&& is_array($environmentVariables))
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pa
|
||||||
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\EditDockerContainer;
|
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\EditDockerContainer;
|
||||||
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\ListDockerContainers;
|
use Modules\Docker\Filament\Clusters\Docker\Resources\DockerContainerResource\Pages\ListDockerContainers;
|
||||||
use Modules\Docker\PostInstall;
|
use Modules\Docker\PostInstall;
|
||||||
|
use Psy\Util\Str;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class DockerTest extends TestCase
|
class DockerTest extends TestCase
|
||||||
|
@ -23,6 +24,9 @@ class DockerTest extends TestCase
|
||||||
ini_set('max_execution_time', 0);
|
ini_set('max_execution_time', 0);
|
||||||
|
|
||||||
$this->actingAs(User::factory()->create());
|
$this->actingAs(User::factory()->create());
|
||||||
|
if (!is_file('/usr/local/phyre/web/storage/installed')) {
|
||||||
|
file_put_contents('/usr/local/phyre/web/storage/installed', '');
|
||||||
|
}
|
||||||
|
|
||||||
$modulesTest = Livewire::test(Modules::class);
|
$modulesTest = Livewire::test(Modules::class);
|
||||||
$modulesTest->call('openInstallModal', 'Docker');
|
$modulesTest->call('openInstallModal', 'Docker');
|
||||||
|
@ -59,17 +63,17 @@ class DockerTest extends TestCase
|
||||||
$pullDockerImage = $dockerCatalogTest->call('pullDockerImage', $dockerImage)
|
$pullDockerImage = $dockerCatalogTest->call('pullDockerImage', $dockerImage)
|
||||||
->assertSee('Pull Docker Image');
|
->assertSee('Pull Docker Image');
|
||||||
|
|
||||||
$isDokerImagePulled = false;
|
|
||||||
$pullLog = '';
|
$pullLog = '';
|
||||||
|
$isDockerImagePulled = false;
|
||||||
for ($i = 0; $i < 300; $i++) {
|
for ($i = 0; $i < 300; $i++) {
|
||||||
$pullLog = @file_get_contents($pullDockerImage->get('pullLogFile'));
|
$pullLog = @file_get_contents($pullDockerImage->get('pullLogFile'));
|
||||||
if (strpos($pullLog, 'DONE!') !== false) {
|
if (str_contains($pullLog, 'DONE!')) {
|
||||||
$isDokerImagePulled = true;
|
$isDockerImagePulled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
$this->assertTrue($isDokerImagePulled);
|
$this->assertTrue($isDockerImagePulled);
|
||||||
|
|
||||||
$this->assertNotEmpty($pullLog);
|
$this->assertNotEmpty($pullLog);
|
||||||
$this->assertStringContainsString('DONE!', $pullLog);
|
$this->assertStringContainsString('DONE!', $pullLog);
|
||||||
|
@ -77,7 +81,7 @@ class DockerTest extends TestCase
|
||||||
$createDockerContainerTest = Livewire::test(CreateDockerContainer::class);
|
$createDockerContainerTest = Livewire::test(CreateDockerContainer::class);
|
||||||
$createDockerContainerTest->assertSee('Create Docker Container');
|
$createDockerContainerTest->assertSee('Create Docker Container');
|
||||||
|
|
||||||
$dockerName = 'nginx-latest-phyre-'.rand(1111,9999);
|
$dockerName = \Illuminate\Support\Str::random(10);
|
||||||
$create = $createDockerContainerTest->fillForm([
|
$create = $createDockerContainerTest->fillForm([
|
||||||
'name' => $dockerName,
|
'name' => $dockerName,
|
||||||
'image' => 'nginx',
|
'image' => 'nginx',
|
||||||
|
|
Loading…
Reference in a new issue