Skip to content

Commit

Permalink
Merge pull request coollabsio#3350 from coollabsio/next
Browse files Browse the repository at this point in the history
v4.0.0-beta.331
  • Loading branch information
andrasbacsai authored Sep 7, 2024
2 parents 254611d + bb1454d commit 435c0ba
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 8 deletions.
44 changes: 42 additions & 2 deletions app/Jobs/DatabaseBackupJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Str;
use App\Models\InstanceSettings;

class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
{
Expand Down Expand Up @@ -493,12 +494,15 @@ private function upload_to_s3(): void
} else {
$network = $this->database->destination->network;
}
$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";

$this->ensureHelperImageAvailable();

$fullImageName = $this->getFullImageName();
$commands[] = "docker run -d --network {$network} --name backup-of-{$this->backup->uuid} --rm -v $this->backup_location:$this->backup_location:ro {$fullImageName}";
$commands[] = "docker exec backup-of-{$this->backup->uuid} mc config host add temporary {$endpoint} $key $secret";
$commands[] = "docker exec backup-of-{$this->backup->uuid} mc cp $this->backup_location temporary/$bucket{$this->backup_dir}/";
instant_remote_process($commands, $this->server);
$this->add_to_backup_output('Uploaded to S3.');
ray('Uploaded to S3. '.$this->backup_location.' to s3://'.$bucket.$this->backup_dir);
} catch (\Throwable $e) {
$this->add_to_backup_output($e->getMessage());
throw $e;
Expand All @@ -507,4 +511,40 @@ private function upload_to_s3(): void
instant_remote_process([$command], $this->server);
}
}

private function ensureHelperImageAvailable(): void
{
$fullImageName = $this->getFullImageName();

$imageExists = $this->checkImageExists($fullImageName);

if (!$imageExists) {
$this->pullHelperImage($fullImageName);
}
}

private function checkImageExists(string $fullImageName): bool
{
$result = instant_remote_process(["docker image inspect {$fullImageName} >/dev/null 2>&1 && echo 'exists' || echo 'not exists'"], $this->server, false);
return trim($result) === 'exists';
}

private function pullHelperImage(string $fullImageName): void
{
try {
instant_remote_process(["docker pull {$fullImageName}"], $this->server);
} catch (\Exception $e) {
$errorMessage = "Failed to pull helper image: " . $e->getMessage();
$this->add_to_backup_output($errorMessage);
throw new \RuntimeException($errorMessage);
}
}

private function getFullImageName(): string
{
$settings = InstanceSettings::get();
$helperImage = config('coolify.helper_image');
$latestVersion = $settings->helper_version;
return "{$helperImage}:{$latestVersion}";
}
}
2 changes: 1 addition & 1 deletion config/sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// 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.330',
'release' => '4.0.0-beta.331',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),

Expand Down
2 changes: 1 addition & 1 deletion config/version.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

return '4.0.0-beta.330';
return '4.0.0-beta.331';
2 changes: 1 addition & 1 deletion templates/compose/plunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_SES_CONFIGURATION_SET=${AWS_SES_CONFIGURATION_SET}
- NEXT_PUBLIC_API_URI=${SERVICE_FQDN_PLUNK}/api
- NEXT_PUBLIC_API_URI=${API_URI}
- APP_URI=${SERVICE_FQDN_PLUNK}
- API_URI=${SERVICE_FQDN_PLUNK}/api
- DISABLE_SIGNUPS=False
Expand Down
2 changes: 1 addition & 1 deletion templates/service-templates.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"coolify": {
"v4": {
"version": "4.0.0-beta.330"
"version": "4.0.0-beta.331"
},
"nightly": {
"version": "4.0.0-beta.331"
"version": "4.0.0-beta.332"
},
"helper": {
"version": "1.0.0"
Expand Down

0 comments on commit 435c0ba

Please sign in to comment.