Skip to content

Commit d2a8f31

Browse files
authored
Merge branch 'next' into custom-traefik-middlewares
2 parents 1b0e2e1 + 2468d00 commit d2a8f31

File tree

147 files changed

+2123
-498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+2123
-498
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Coolify Realtime Development (v4)
2+
3+
on:
4+
push:
5+
branches: [ "next" ]
6+
paths:
7+
- .github/workflows/coolify-realtime.yml
8+
- docker/coolify-realtime/Dockerfile
9+
- docker/coolify-realtime/terminal-server.js
10+
- docker/coolify-realtime/package.json
11+
- docker/coolify-realtime/soketi-entrypoint.sh
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: "coollabsio/coolify-realtime"
16+
17+
jobs:
18+
amd64:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Login to ghcr.io
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
- name: Get Version
32+
id: version
33+
run: |
34+
echo "VERSION=$(docker run --rm -v "$(pwd):/app" -w /app ghcr.io/jqlang/jq:latest '.coolify.realtime.version' versions.json)"|xargs >> $GITHUB_OUTPUT
35+
- name: Build image and push to registry
36+
uses: docker/build-push-action@v5
37+
with:
38+
no-cache: true
39+
context: .
40+
file: docker/coolify-realtime/Dockerfile
41+
platforms: linux/amd64
42+
push: true
43+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}-next
44+
labels: |
45+
coolify.managed=true
46+
aarch64:
47+
runs-on: [ self-hosted, arm64 ]
48+
permissions:
49+
contents: read
50+
packages: write
51+
steps:
52+
- uses: actions/checkout@v4
53+
- name: Login to ghcr.io
54+
uses: docker/login-action@v3
55+
with:
56+
registry: ${{ env.REGISTRY }}
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
- name: Get Version
60+
id: version
61+
run: |
62+
echo "VERSION=$(docker run --rm -v "$(pwd):/app" -w /app ghcr.io/jqlang/jq:latest '.coolify.realtime.version' versions.json)"|xargs >> $GITHUB_OUTPUT
63+
- name: Build image and push to registry
64+
uses: docker/build-push-action@v5
65+
with:
66+
no-cache: true
67+
context: .
68+
file: docker/coolify-realtime/Dockerfile
69+
platforms: linux/aarch64
70+
push: true
71+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}-next-aarch64
72+
labels: |
73+
coolify.managed=true
74+
merge-manifest:
75+
runs-on: ubuntu-latest
76+
permissions:
77+
contents: read
78+
packages: write
79+
needs: [ amd64, aarch64 ]
80+
steps:
81+
- name: Checkout
82+
uses: actions/checkout@v4
83+
- name: Set up QEMU
84+
uses: docker/setup-qemu-action@v3
85+
- name: Set up Docker Buildx
86+
uses: docker/setup-buildx-action@v3
87+
- name: Login to ghcr.io
88+
uses: docker/login-action@v3
89+
with:
90+
registry: ${{ env.REGISTRY }}
91+
username: ${{ github.actor }}
92+
password: ${{ secrets.GITHUB_TOKEN }}
93+
- name: Get Version
94+
id: version
95+
run: |
96+
echo "VERSION=$(docker run --rm -v "$(pwd):/app" -w /app ghcr.io/jqlang/jq:latest '.coolify.realtime.version' versions.json)"|xargs >> $GITHUB_OUTPUT
97+
- name: Create & publish manifest
98+
run: |
99+
docker buildx imagetools create --append ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}-next-aarch64 --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION }}-next
100+
- uses: sarisia/actions-status-discord@v1
101+
if: always()
102+
with:
103+
webhook: ${{ secrets.DISCORD_WEBHOOK_PROD_RELEASE_CHANNEL }}

.github/workflows/coolify-realtime.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Coolify Realtime (v4)
22

33
on:
44
push:
5-
branches: [ "main", "next" ]
5+
branches: [ "main" ]
66
paths:
77
- .github/workflows/coolify-realtime.yml
88
- docker/coolify-realtime/Dockerfile

app/Actions/Database/StartDragonfly.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ public function handle(StandaloneDragonfly $database)
4646
'networks' => [
4747
$this->database->destination->network,
4848
],
49-
'ulimits' => [
50-
'memlock' => '-1',
51-
],
5249
'labels' => [
5350
'coolify.managed' => 'true',
5451
],

app/Actions/Fortify/CreateNewUser.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace App\Actions\Fortify;
44

5-
use App\Models\InstanceSettings;
65
use App\Models\User;
76
use Illuminate\Support\Facades\Hash;
87
use Illuminate\Support\Facades\Validator;
@@ -20,7 +19,7 @@ class CreateNewUser implements CreatesNewUsers
2019
*/
2120
public function create(array $input): User
2221
{
23-
$settings = InstanceSettings::get();
22+
$settings = instanceSettings();
2423
if (! $settings->is_registration_enabled) {
2524
abort(403);
2625
}
@@ -48,7 +47,7 @@ public function create(array $input): User
4847
$team = $user->teams()->first();
4948

5049
// Disable registration after first user is created
51-
$settings = InstanceSettings::get();
50+
$settings = instanceSettings();
5251
$settings->is_registration_enabled = false;
5352
$settings->save();
5453
} else {

app/Actions/License/CheckResaleLicense.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace App\Actions\License;
44

5-
use App\Models\InstanceSettings;
65
use Illuminate\Support\Facades\Http;
76
use Lorisleiva\Actions\Concerns\AsAction;
87

@@ -13,7 +12,7 @@ class CheckResaleLicense
1312
public function handle()
1413
{
1514
try {
16-
$settings = InstanceSettings::get();
15+
$settings = instanceSettings();
1716
if (isDev()) {
1817
$settings->update([
1918
'is_resale_license_active' => true,

app/Actions/Proxy/CheckProxy.php

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
namespace App\Actions\Proxy;
44

5+
use App\Enums\ProxyTypes;
56
use App\Models\Server;
67
use Lorisleiva\Actions\Concerns\AsAction;
8+
use Symfony\Component\Yaml\Yaml;
79

810
class CheckProxy
911
{
1012
use AsAction;
1113

12-
public function handle(Server $server, $fromUI = false)
14+
// It should return if the proxy should be started (true) or not (false)
15+
public function handle(Server $server, $fromUI = false): bool
1316
{
1417
if (! $server->isFunctional()) {
1518
return false;
@@ -62,22 +65,42 @@ public function handle(Server $server, $fromUI = false)
6265
$ip = 'host.docker.internal';
6366
}
6467

65-
$connection80 = @fsockopen($ip, '80');
66-
$connection443 = @fsockopen($ip, '443');
67-
$port80 = is_resource($connection80) && fclose($connection80);
68-
$port443 = is_resource($connection443) && fclose($connection443);
69-
if ($port80) {
70-
if ($fromUI) {
71-
throw new \Exception("Port 80 is in use.<br>You must stop the process using this port.<br>Docs: <a target='_blank' href='https://coolify.io/docs'>https://coolify.io/docs</a><br>Discord: <a target='_blank' href='https://coollabs.io/discord'>https://coollabs.io/discord</a>");
68+
$portsToCheck = ['80', '443'];
69+
70+
try {
71+
if ($server->proxyType() !== ProxyTypes::NONE->value) {
72+
$proxyCompose = CheckConfiguration::run($server);
73+
if (isset($proxyCompose)) {
74+
$yaml = Yaml::parse($proxyCompose);
75+
$portsToCheck = [];
76+
if ($server->proxyType() === ProxyTypes::TRAEFIK->value) {
77+
$ports = data_get($yaml, 'services.traefik.ports');
78+
} elseif ($server->proxyType() === ProxyTypes::CADDY->value) {
79+
$ports = data_get($yaml, 'services.caddy.ports');
80+
}
81+
if (isset($ports)) {
82+
foreach ($ports as $port) {
83+
$portsToCheck[] = str($port)->before(':')->value();
84+
}
85+
}
86+
}
7287
} else {
73-
return false;
88+
$portsToCheck = [];
7489
}
90+
} catch (\Exception $e) {
91+
ray($e->getMessage());
7592
}
76-
if ($port443) {
77-
if ($fromUI) {
78-
throw new \Exception("Port 443 is in use.<br>You must stop the process using this port.<br>Docs: <a target='_blank' href='https://coolify.io/docs'>https://coolify.io/docs</a><br>Discord: <a target='_blank' href='https://coollabs.io/discord'>https://coollabs.io/discord</a>");
79-
} else {
80-
return false;
93+
if (count($portsToCheck) === 0) {
94+
return false;
95+
}
96+
foreach ($portsToCheck as $port) {
97+
$connection = @fsockopen($ip, $port);
98+
if (is_resource($connection) && fclose($connection)) {
99+
if ($fromUI) {
100+
throw new \Exception("Port $port is in use.<br>You must stop the process using this port.<br>Docs: <a target='_blank' href='https://coolify.io/docs'>https://coolify.io/docs</a><br>Discord: <a target='_blank' href='https://coollabs.io/discord'>https://coollabs.io/discord</a>");
101+
} else {
102+
return false;
103+
}
81104
}
82105
}
83106

app/Actions/Server/CleanupDocker.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace App\Actions\Server;
44

5-
use App\Models\InstanceSettings;
65
use App\Models\Server;
76
use Lorisleiva\Actions\Concerns\AsAction;
87

@@ -12,7 +11,7 @@ class CleanupDocker
1211

1312
public function handle(Server $server)
1413
{
15-
$settings = InstanceSettings::get();
14+
$settings = instanceSettings();
1615
$helperImageVersion = data_get($settings, 'helper_version');
1716
$helperImage = config('coolify.helper_image');
1817
$helperImageWithVersion = "$helperImage:$helperImageVersion";

app/Actions/Server/UpdateCoolify.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Actions\Server;
44

55
use App\Jobs\PullHelperImageJob;
6-
use App\Models\InstanceSettings;
76
use App\Models\Server;
87
use Lorisleiva\Actions\Concerns\AsAction;
98

@@ -20,7 +19,7 @@ class UpdateCoolify
2019
public function handle($manual_update = false)
2120
{
2221
try {
23-
$settings = InstanceSettings::get();
22+
$settings = instanceSettings();
2423
$this->server = Server::find(0);
2524
if (! $this->server) {
2625
return;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Enums\ApplicationDeploymentStatus;
6+
use App\Models\ApplicationDeploymentQueue;
7+
use Illuminate\Console\Command;
8+
9+
class CheckApplicationDeploymentQueue extends Command
10+
{
11+
protected $signature = 'check:deployment-queue {--force} {--seconds=3600}';
12+
13+
protected $description = 'Check application deployment queue.';
14+
15+
public function handle()
16+
{
17+
$seconds = $this->option('seconds');
18+
$deployments = ApplicationDeploymentQueue::whereIn('status', [
19+
ApplicationDeploymentStatus::IN_PROGRESS,
20+
ApplicationDeploymentStatus::QUEUED,
21+
])->where('created_at', '<=', now()->subSeconds($seconds))->get();
22+
if ($deployments->isEmpty()) {
23+
$this->info('No deployments found in the last '.$seconds.' seconds.');
24+
25+
return;
26+
}
27+
28+
$this->info('Found '.$deployments->count().' deployments created in the last '.$seconds.' seconds.');
29+
30+
foreach ($deployments as $deployment) {
31+
if ($this->option('force')) {
32+
$this->info('Deployment '.$deployment->id.' created at '.$deployment->created_at.' is older than '.$seconds.' seconds. Setting status to failed.');
33+
$this->cancelDeployment($deployment);
34+
} else {
35+
$this->info('Deployment '.$deployment->id.' created at '.$deployment->created_at.' is older than '.$seconds.' seconds. Setting status to failed.');
36+
if ($this->confirm('Do you want to cancel this deployment?', true)) {
37+
$this->cancelDeployment($deployment);
38+
}
39+
}
40+
}
41+
}
42+
43+
private function cancelDeployment(ApplicationDeploymentQueue $deployment)
44+
{
45+
$deployment->update(['status' => ApplicationDeploymentStatus::FAILED]);
46+
if ($deployment->server?->isFunctional()) {
47+
remote_process(['docker rm -f '.$deployment->deployment_uuid], $deployment->server, false);
48+
}
49+
}
50+
}

app/Console/Commands/CleanupApplicationDeploymentQueue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
class CleanupApplicationDeploymentQueue extends Command
99
{
10-
protected $signature = 'cleanup:application-deployment-queue {--team-id=}';
10+
protected $signature = 'cleanup:deployment-queue {--team-id=}';
1111

12-
protected $description = 'CleanupApplicationDeploymentQueue';
12+
protected $description = 'Cleanup application deployment queue.';
1313

1414
public function handle()
1515
{

0 commit comments

Comments
 (0)