mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-21 23:20:24 +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();
|
||||
|
||||
if (!isset($createContainer['ID'])) {
|
||||
throw new \Exception('Failed to create container');
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ class DockerContainerApi
|
|||
'externalPort' => $this->externalPort,
|
||||
'environmentVariables' => $this->environmentVariables,
|
||||
'volumeMapping' => $this->volumeMapping,
|
||||
'version' => '3'
|
||||
])->render();
|
||||
}
|
||||
|
||||
|
@ -84,6 +85,7 @@ class DockerContainerApi
|
|||
shell_exec('mkdir -p ' . $dockerContaienrPath);
|
||||
}
|
||||
|
||||
|
||||
$dockerComposeFile = $dockerContaienrPath . '/docker-compose.yml';
|
||||
file_put_contents($dockerComposeFile, $dockerComposeFileContent);
|
||||
|
||||
|
|
|
@ -5,12 +5,14 @@ version: '{{$version}}'
|
|||
services:
|
||||
|
||||
{{$name}}:
|
||||
image: {{$image}}
|
||||
image: "{{$image}}"
|
||||
restart: always
|
||||
ports:
|
||||
- {{$externalPort}}:{{ $port }}
|
||||
|
||||
@if(isset($environmentVariables) && !empty($environmentVariables))
|
||||
@if(isset($environmentVariables)
|
||||
&& !empty($environmentVariables)
|
||||
&& is_array($environmentVariables))
|
||||
|
||||
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\ListDockerContainers;
|
||||
use Modules\Docker\PostInstall;
|
||||
use Psy\Util\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DockerTest extends TestCase
|
||||
|
@ -23,6 +24,9 @@ class DockerTest extends TestCase
|
|||
ini_set('max_execution_time', 0);
|
||||
|
||||
$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->call('openInstallModal', 'Docker');
|
||||
|
@ -59,17 +63,17 @@ class DockerTest extends TestCase
|
|||
$pullDockerImage = $dockerCatalogTest->call('pullDockerImage', $dockerImage)
|
||||
->assertSee('Pull Docker Image');
|
||||
|
||||
$isDokerImagePulled = false;
|
||||
$pullLog = '';
|
||||
$isDockerImagePulled = false;
|
||||
for ($i = 0; $i < 300; $i++) {
|
||||
$pullLog = @file_get_contents($pullDockerImage->get('pullLogFile'));
|
||||
if (strpos($pullLog, 'DONE!') !== false) {
|
||||
$isDokerImagePulled = true;
|
||||
if (str_contains($pullLog, 'DONE!')) {
|
||||
$isDockerImagePulled = true;
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
$this->assertTrue($isDokerImagePulled);
|
||||
$this->assertTrue($isDockerImagePulled);
|
||||
|
||||
$this->assertNotEmpty($pullLog);
|
||||
$this->assertStringContainsString('DONE!', $pullLog);
|
||||
|
@ -77,7 +81,7 @@ class DockerTest extends TestCase
|
|||
$createDockerContainerTest = Livewire::test(CreateDockerContainer::class);
|
||||
$createDockerContainerTest->assertSee('Create Docker Container');
|
||||
|
||||
$dockerName = 'nginx-latest-phyre-'.rand(1111,9999);
|
||||
$dockerName = \Illuminate\Support\Str::random(10);
|
||||
$create = $createDockerContainerTest->fillForm([
|
||||
'name' => $dockerName,
|
||||
'image' => 'nginx',
|
||||
|
|
Loading…
Reference in a new issue