deploymentPlan = new Plan(steps: [ new Step( name: 'Check docker is installed', script: 'command -v docker >/dev/null 2>&1 || { echo >&2 "Docker is not installed. Aborting."; exit 1; }', ), new Step( name: 'Run the docker image', secrets: [ 'defaultpassword' => $this->defaultPassword, ], script: function () { $script = collect(); if ($this->containerName) { $script->push('docker stop ' . $this->containerName . ' || true'); } else if ($this->containerId) { $script->push('docker stop ' . $this->containerId . ' || true'); } $runCommand = "docker run -d"; if ($this->containerName) { $runCommand .= " --name {$this->containerName}"; } if ($this->defaultPassword) { $runCommand .= " -e POSTGRES_PASSWORD=[!defaultPassword!]"; } if ($this->defaultUser) { $runCommand .= " -e POSTGRES_USER={$this->defaultUser}"; } if ($this->defaultDb) { $runCommand .= " -e POSTGRES_DB={$this->defaultDb}"; } $runCommand .= " -p 5432:5432 postgres:17"; return $runCommand; } ) ]); } }