Skip to content

Commit 435c0ba

Browse files
authored
Merge pull request coollabsio#3350 from coollabsio/next
v4.0.0-beta.331
2 parents 254611d + bb1454d commit 435c0ba

File tree

6 files changed

+48
-8
lines changed

6 files changed

+48
-8
lines changed

app/Jobs/DatabaseBackupJob.php

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Illuminate\Queue\Middleware\WithoutOverlapping;
2626
use Illuminate\Queue\SerializesModels;
2727
use Illuminate\Support\Str;
28+
use App\Models\InstanceSettings;
2829

2930
class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
3031
{
@@ -493,12 +494,15 @@ private function upload_to_s3(): void
493494
} else {
494495
$network = $this->database->destination->network;
495496
}
496-
$commands[] = "docker run -d --network {$network} --name backup-of-{$this->backup->uuid} --rm -v $this->backup_location:$this->backup_location:ro ghcr.io/coollabsio/coolify-helper";
497+
498+
$this->ensureHelperImageAvailable();
499+
500+
$fullImageName = $this->getFullImageName();
501+
$commands[] = "docker run -d --network {$network} --name backup-of-{$this->backup->uuid} --rm -v $this->backup_location:$this->backup_location:ro {$fullImageName}";
497502
$commands[] = "docker exec backup-of-{$this->backup->uuid} mc config host add temporary {$endpoint} $key $secret";
498503
$commands[] = "docker exec backup-of-{$this->backup->uuid} mc cp $this->backup_location temporary/$bucket{$this->backup_dir}/";
499504
instant_remote_process($commands, $this->server);
500505
$this->add_to_backup_output('Uploaded to S3.');
501-
ray('Uploaded to S3. '.$this->backup_location.' to s3://'.$bucket.$this->backup_dir);
502506
} catch (\Throwable $e) {
503507
$this->add_to_backup_output($e->getMessage());
504508
throw $e;
@@ -507,4 +511,40 @@ private function upload_to_s3(): void
507511
instant_remote_process([$command], $this->server);
508512
}
509513
}
514+
515+
private function ensureHelperImageAvailable(): void
516+
{
517+
$fullImageName = $this->getFullImageName();
518+
519+
$imageExists = $this->checkImageExists($fullImageName);
520+
521+
if (!$imageExists) {
522+
$this->pullHelperImage($fullImageName);
523+
}
524+
}
525+
526+
private function checkImageExists(string $fullImageName): bool
527+
{
528+
$result = instant_remote_process(["docker image inspect {$fullImageName} >/dev/null 2>&1 && echo 'exists' || echo 'not exists'"], $this->server, false);
529+
return trim($result) === 'exists';
530+
}
531+
532+
private function pullHelperImage(string $fullImageName): void
533+
{
534+
try {
535+
instant_remote_process(["docker pull {$fullImageName}"], $this->server);
536+
} catch (\Exception $e) {
537+
$errorMessage = "Failed to pull helper image: " . $e->getMessage();
538+
$this->add_to_backup_output($errorMessage);
539+
throw new \RuntimeException($errorMessage);
540+
}
541+
}
542+
543+
private function getFullImageName(): string
544+
{
545+
$settings = InstanceSettings::get();
546+
$helperImage = config('coolify.helper_image');
547+
$latestVersion = $settings->helper_version;
548+
return "{$helperImage}:{$latestVersion}";
549+
}
510550
}

config/sentry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// The release version of your application
99
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
10-
'release' => '4.0.0-beta.330',
10+
'release' => '4.0.0-beta.331',
1111
// When left empty or `null` the Laravel environment will be used
1212
'environment' => config('app.env'),
1313

config/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
return '4.0.0-beta.330';
3+
return '4.0.0-beta.331';

templates/compose/plunk.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ services:
2222
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
2323
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
2424
- AWS_SES_CONFIGURATION_SET=${AWS_SES_CONFIGURATION_SET}
25-
- NEXT_PUBLIC_API_URI=${SERVICE_FQDN_PLUNK}/api
25+
- NEXT_PUBLIC_API_URI=${API_URI}
2626
- APP_URI=${SERVICE_FQDN_PLUNK}
2727
- API_URI=${SERVICE_FQDN_PLUNK}/api
2828
- DISABLE_SIGNUPS=False

templates/service-templates.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

versions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"coolify": {
33
"v4": {
4-
"version": "4.0.0-beta.330"
4+
"version": "4.0.0-beta.331"
55
},
66
"nightly": {
7-
"version": "4.0.0-beta.331"
7+
"version": "4.0.0-beta.332"
88
},
99
"helper": {
1010
"version": "1.0.0"

0 commit comments

Comments
 (0)