mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-21 23:20:24 +00:00
update
This commit is contained in:
parent
02e6953022
commit
671399b606
3 changed files with 32 additions and 8 deletions
|
@ -37,6 +37,9 @@ class DockerContainer extends Model
|
|||
'external_port',
|
||||
'volume_mapping',
|
||||
'environment_variables',
|
||||
'build_type',
|
||||
'docker_template_id',
|
||||
'docker_compose'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
@ -81,6 +84,10 @@ class DockerContainer extends Model
|
|||
$dockerContainerApi->setName(Str::slug($model->name.'-phyre-'.$nextId));
|
||||
$dockerContainerApi->setExternalPort($model->external_port);
|
||||
|
||||
if ($model->build_type == 'template') {
|
||||
$dockerContainerApi->setDockerCompose($model->docker_compose);
|
||||
}
|
||||
|
||||
$createContainer = $dockerContainerApi->run();
|
||||
if (!isset($createContainer['ID'])) {
|
||||
return false;
|
||||
|
|
|
@ -14,6 +14,8 @@ class DockerContainerApi
|
|||
public $port = '';
|
||||
public $externalPort = '';
|
||||
|
||||
public $dockerCompose = '';
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$name = trim($name);
|
||||
|
@ -47,6 +49,11 @@ class DockerContainerApi
|
|||
$this->externalPort = $externalPort;
|
||||
}
|
||||
|
||||
public function setDockerCompose($dockerCompose)
|
||||
{
|
||||
$this->dockerCompose = $dockerCompose;
|
||||
}
|
||||
|
||||
public function recreate($containerId)
|
||||
{
|
||||
shell_exec('docker stop ' . $containerId);
|
||||
|
@ -59,14 +66,18 @@ class DockerContainerApi
|
|||
{
|
||||
$commandId = rand(10000, 99999);
|
||||
|
||||
$dockerComposeFileContent = view('docker::actions.docker-compose-yml', [
|
||||
'name' => $this->name,
|
||||
'image' => $this->image,
|
||||
'port' => $this->port,
|
||||
'externalPort' => $this->externalPort,
|
||||
'environmentVariables' => $this->environmentVariables,
|
||||
'volumeMapping' => $this->volumeMapping,
|
||||
])->render();
|
||||
if (!empty($this->dockerCompose)) {
|
||||
$dockerComposeFileContent = $this->dockerCompose;
|
||||
} else {
|
||||
$dockerComposeFileContent = view('docker::actions.docker-compose-yml', [
|
||||
'name' => $this->name,
|
||||
'image' => $this->image,
|
||||
'port' => $this->port,
|
||||
'externalPort' => $this->externalPort,
|
||||
'environmentVariables' => $this->environmentVariables,
|
||||
'volumeMapping' => $this->volumeMapping,
|
||||
])->render();
|
||||
}
|
||||
|
||||
$dockerContaienrPath = storage_path('docker/'.$this->name);
|
||||
if (!is_dir($dockerContaienrPath)) {
|
||||
|
|
|
@ -144,12 +144,18 @@ class DockerContainerResource extends Resource
|
|||
|
||||
Forms\Components\TextInput::make('port')
|
||||
->label('Port')
|
||||
->hidden(function (Forms\Get $get) {
|
||||
return $get('build_type') != 'image';
|
||||
})
|
||||
// ->disabled()
|
||||
->default($defaultPort)
|
||||
->columnSpan(1),
|
||||
|
||||
Forms\Components\TextInput::make('external_port')
|
||||
->label('External Port')
|
||||
->hidden(function (Forms\Get $get) {
|
||||
return $get('build_type') != 'image';
|
||||
})
|
||||
// ->disabled()
|
||||
->default($defaultExternalPort)
|
||||
->columnSpan(1),
|
||||
|
|
Loading…
Reference in a new issue