diff --git a/app/Http/Livewire/Project/Application/DeploymentNavbar.php b/app/Http/Livewire/Project/Application/DeploymentNavbar.php
index b0cad0395..0cdb895c8 100644
--- a/app/Http/Livewire/Project/Application/DeploymentNavbar.php
+++ b/app/Http/Livewire/Project/Application/DeploymentNavbar.php
@@ -60,12 +60,16 @@ class DeploymentNavbar extends Component
$previous_logs[] = $new_log_entry;
$this->application_deployment_queue->update([
'logs' => json_encode($previous_logs, flags: JSON_THROW_ON_ERROR),
- 'current_process_id' => null,
- 'status' => ApplicationDeploymentStatus::CANCELLED_BY_USER->value,
]);
}
} catch (\Throwable $e) {
return handleError($e, $this);
+ } finally {
+ $this->application_deployment_queue->update([
+ 'current_process_id' => null,
+ 'status' => ApplicationDeploymentStatus::CANCELLED_BY_USER->value,
+ ]);
+ queue_next_deployment($this->application);
}
}
}
diff --git a/app/Http/Livewire/Project/Service/Navbar.php b/app/Http/Livewire/Project/Service/Navbar.php
index d85c6f435..b8e604ad4 100644
--- a/app/Http/Livewire/Project/Service/Navbar.php
+++ b/app/Http/Livewire/Project/Service/Navbar.php
@@ -34,5 +34,6 @@ class Navbar extends Component
StopService::run($this->service);
$this->service->refresh();
$this->emit('success', 'Service stopped successfully.');
+ $this->checkStatus();
}
}
diff --git a/app/Http/Livewire/Project/Service/StackForm.php b/app/Http/Livewire/Project/Service/StackForm.php
index 1518e3d22..2c1fa5495 100644
--- a/app/Http/Livewire/Project/Service/StackForm.php
+++ b/app/Http/Livewire/Project/Service/StackForm.php
@@ -6,6 +6,7 @@ use Livewire\Component;
class StackForm extends Component
{
+ public $service;
protected $listeners = ["saveCompose"];
protected $rules = [
'service.docker_compose_raw' => 'required',
@@ -13,7 +14,6 @@ class StackForm extends Component
'service.name' => 'required',
'service.description' => 'nullable',
];
- public $service;
public function saveCompose($raw)
{
$this->service->docker_compose_raw = $raw;
diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php
index 3b9c74b90..ff4228ac5 100644
--- a/app/Jobs/ApplicationDeploymentJob.php
+++ b/app/Jobs/ApplicationDeploymentJob.php
@@ -67,10 +67,13 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
private $docker_compose;
private $docker_compose_base64;
private string $dockerfile_location = '/Dockerfile';
-
+ private ?string $addHosts = null;
private $log_model;
private Collection $saved_outputs;
+ private string $serverUser = 'root';
+ private string $serverUserHomeDir = '/root';
+
public $tries = 1;
public function __construct(int $application_deployment_queue_id)
{
@@ -92,13 +95,12 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
}
$this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
$this->server = $this->destination->server;
-
+ $this->serverUser = $this->server->user;
$this->basedir = "/artifacts/{$this->deployment_uuid}";
$this->workdir = "{$this->basedir}" . rtrim($this->application->base_directory, '/');
$this->configuration_dir = application_configuration_dir() . "/{$this->application->uuid}";
$this->is_debug_enabled = $this->application->settings->is_debug_enabled;
- ray($this->basedir, $this->workdir);
$this->container_name = generateApplicationContainerName($this->application, $this->pull_request_id);
savePrivateKeyToFs($this->server);
$this->saved_outputs = collect();
@@ -138,6 +140,31 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
$this->application_deployment_queue->update([
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
]);
+
+ // Generate custom host<->ip mapping
+ $allContainers = instant_remote_process(["docker network inspect {$this->destination->network} -f '{{json .Containers}}' "], $this->server);
+ $allContainers = format_docker_command_output_to_json($allContainers);
+ $ips = collect([]);
+ if (count($allContainers) > 0) {
+ $allContainers = $allContainers[0];
+ foreach ($allContainers as $container) {
+ $containerName = data_get($container, 'Name');
+ if ($containerName === 'coolify-proxy') {
+ continue;
+ }
+ $containerIp = data_get($container, 'IPv4Address');
+ if ($containerName && $containerIp) {
+ $containerIp = str($containerIp)->before('/');
+ $ips->put($containerName, $containerIp->value());
+ }
+ }
+ }
+ $this->addHosts = $ips->map(function ($ip, $name) {
+ return "--add-host $name:$ip";
+ })->implode(' ');
+
+ // Get user home directory
+ $this->serverUserHomeDir = instant_remote_process(["echo \$HOME"], $this->server);
try {
if ($this->application->dockerfile) {
$this->deploy_simple_dockerfile();
@@ -436,7 +463,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
{
$pull = "--pull=always";
$helperImage = config('coolify.helper_image');
- $runCommand = "docker run {$pull} -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}";
+ $runCommand = "docker run {$pull} -d --network {$this->destination->network} -v /:/host --name {$this->deployment_uuid} --rm -v {$this->serverUserHomeDir}/.docker/config.json:/root/.docker/config.json:ro -v /var/run/docker.sock:/var/run/docker.sock {$helperImage}";
$this->execute_remote_command(
[
@@ -766,7 +793,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
if ($this->application->settings->is_static) {
$this->execute_remote_command([
- executeInDocker($this->deployment_uuid, "docker build --network host -f {$this->workdir}/{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true
+ executeInDocker($this->deployment_uuid, "docker build $this->addHosts --network host -f {$this->workdir}/{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"), "hidden" => true
]);
$dockerfile = base64_encode("FROM {$this->application->static_image}
@@ -799,12 +826,13 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
executeInDocker($this->deployment_uuid, "echo '{$nginx_config}' | base64 -d > {$this->workdir}/nginx.conf")
],
[
- executeInDocker($this->deployment_uuid, "docker build --network host -f {$this->workdir}/Dockerfile-prod {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
+ executeInDocker($this->deployment_uuid, "docker build $this->addHosts --network host -f {$this->workdir}/Dockerfile-prod {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
]
);
} else {
+ ray("docker build $this->addHosts --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}");
$this->execute_remote_command([
- executeInDocker($this->deployment_uuid, "docker build --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
+ executeInDocker($this->deployment_uuid, "docker build $this->addHosts --network host -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->production_image_name {$this->workdir}"), "hidden" => true
]);
}
}
diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php
index b68a7c89b..4f379ec65 100644
--- a/app/Jobs/ContainerStatusJob.php
+++ b/app/Jobs/ContainerStatusJob.php
@@ -47,7 +47,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
public function handle()
{
try {
- ray("checking server status for {$this->server->id}");
+ // ray("checking server status for {$this->server->id}");
// ray()->clearAll();
$serverUptimeCheckNumber = $this->server->unreachable_count;
$serverUptimeCheckNumberMax = 3;
diff --git a/app/Models/Service.php b/app/Models/Service.php
index a8a9570f8..4fbb6a1f7 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -382,7 +382,7 @@ class Service extends BaseModel
$value = Str::of($variable);
}
if ($key->startsWith('SERVICE_FQDN')) {
- if ($isNew) {
+ if ($isNew || $savedService->fqdn === null) {
$name = $key->after('SERVICE_FQDN_')->beforeLast('_')->lower();
$fqdn = generateFqdn($this->server, "{$name->value()}-{$this->uuid}");
if (substr_count($key->value(), '_') === 3) {
diff --git a/config/sentry.php b/config/sentry.php
index 9631be2fd..f0fda5f19 100644
--- a/config/sentry.php
+++ b/config/sentry.php
@@ -7,7 +7,7 @@ return [
// The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
- 'release' => '4.0.0-beta.86',
+ 'release' => '4.0.0-beta.88',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),
diff --git a/config/version.php b/config/version.php
index 86fe50176..8de2939a1 100644
--- a/config/version.php
+++ b/config/version.php
@@ -1,3 +1,3 @@
Cancel deployment
+