Skip to content

Commit e83aece

Browse files
authored
Merge pull request coollabsio#3559 from coollabsio/next
v4.0.0-beta.344
2 parents 43df918 + 0bb1f57 commit e83aece

File tree

10 files changed

+54
-93
lines changed

10 files changed

+54
-93
lines changed

app/Jobs/ApplicationDeploymentJob.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,14 +1442,24 @@ private function check_git_if_build_needed()
14421442
if ($this->pull_request_id !== 0) {
14431443
$local_branch = "pull/{$this->pull_request_id}/head";
14441444
}
1445-
$private_key = $this->application->privateKey?->getKeyLocation();
1445+
$private_key = data_get($this->application, 'private_key.private_key');
14461446
if ($private_key) {
1447+
$private_key = base64_encode($private_key);
14471448
$this->execute_remote_command(
14481449
[
1449-
executeInDocker($this->deployment_uuid, "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$this->customPort} -o Port={$this->customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i {$private_key}\" git ls-remote {$this->fullRepoUrl} {$local_branch}"),
1450+
executeInDocker($this->deployment_uuid, 'mkdir -p /root/.ssh'),
1451+
],
1452+
[
1453+
executeInDocker($this->deployment_uuid, "echo '{$private_key}' | base64 -d | tee /root/.ssh/id_rsa > /dev/null"),
1454+
],
1455+
[
1456+
executeInDocker($this->deployment_uuid, 'chmod 600 /root/.ssh/id_rsa'),
1457+
],
1458+
[
1459+
executeInDocker($this->deployment_uuid, "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$this->customPort} -o Port={$this->customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" git ls-remote {$this->fullRepoUrl} {$local_branch}"),
14501460
'hidden' => true,
14511461
'save' => 'git_commit_sha',
1452-
],
1462+
]
14531463
);
14541464
} else {
14551465
$this->execute_remote_command(

app/Livewire/Project/Shared/Terminal.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@
99

1010
class Terminal extends Component
1111
{
12+
public function getListeners()
13+
{
14+
$teamId = auth()->user()->currentTeam()->id;
15+
16+
return [
17+
"echo-private:team.{$teamId},ApplicationStatusChanged" => 'closeTerminal',
18+
];
19+
}
20+
21+
public function closeTerminal()
22+
{
23+
$this->dispatch('reloadWindow');
24+
}
25+
1226
#[On('send-terminal-command')]
1327
public function sendTerminalCommand($isContainer, $identifier, $serverUuid)
1428
{

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.343',
10+
'release' => '4.0.0-beta.344',
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.343';
3+
return '4.0.0-beta.344';

database/seeders/ProductionSeeder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function run(): void
6565
]);
6666
}
6767
// Add Coolify host (localhost) as Server if it doesn't exist
68-
if (Server::find(0) == null) {
68+
if (Server::find(0) == null && ! isCloud()) {
6969
$server_details = [
7070
'id' => 0,
7171
'name' => 'localhost',
@@ -89,7 +89,7 @@ public function run(): void
8989
$server->settings->is_usable = true;
9090
$server->settings->save();
9191
}
92-
if (StandaloneDocker::find(0) == null) {
92+
if (StandaloneDocker::find(0) == null && ! isCloud()) {
9393
StandaloneDocker::create([
9494
'id' => 0,
9595
'name' => 'localhost-coolify',

other/nightly/install.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -o pipefail # Cause a pipeline to return the status of the last command that
88
CDN="https://cdn.coollabs.io/coolify-nightly"
99
DATE=$(date +"%Y%m%d-%H%M%S")
1010

11-
VERSION="1.5"
11+
VERSION="1.6"
1212
DOCKER_VERSION="26.0"
1313
# TODO: Ask for a user
1414
CURRENT_USER=$USER
@@ -39,6 +39,11 @@ if [ "$OS_TYPE" = "manjaro" ] || [ "$OS_TYPE" = "manjaro-arm" ]; then
3939
OS_TYPE="arch"
4040
fi
4141

42+
# Check if the OS is Asahi Linux, if so, change it to fedora
43+
if [ "$OS_TYPE" = "fedora-asahi-remix" ]; then
44+
OS_TYPE="fedora"
45+
fi
46+
4247
# Check if the OS is popOS, if so, change it to ubuntu
4348
if [ "$OS_TYPE" = "pop" ]; then
4449
OS_TYPE="ubuntu"

other/nightly/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.343"
4+
"version": "4.0.0-beta.344"
55
},
66
"nightly": {
7-
"version": "4.0.0-beta.344"
7+
"version": "4.0.0-beta.345"
88
},
99
"helper": {
1010
"version": "1.0.1"

resources/views/livewire/project/shared/execute-container-command.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<x-forms.button type="submit">Connect</x-forms.button>
3333
</form>
3434
@else
35-
<div class="pt-4">No containers are not running.</div>
35+
<div class="pt-4">No containers are running.</div>
3636
@endif
3737
</div>
3838
</div>

scripts/install.sh

Lines changed: 12 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ DATE=$(date +"%Y%m%d-%H%M%S")
1010

1111
VERSION="1.6"
1212
DOCKER_VERSION="26.0"
13+
# TODO: Ask for a user
14+
CURRENT_USER=$USER
1315

1416
mkdir -p /data/coolify/{source,ssh,applications,databases,backups,services,proxy,webhooks-during-maintenance,metrics,logs}
1517
mkdir -p /data/coolify/ssh/{keys,mux}
@@ -401,88 +403,18 @@ if [ ! -f ~/.ssh/authorized_keys ]; then
401403
chmod 600 ~/.ssh/authorized_keys
402404
fi
403405

404-
checkSshKeyInAuthorizedKeys() {
405-
grep -qw "root@coolify" ~/.ssh/authorized_keys
406-
return $?
407-
}
408-
409-
checkSshKeyInCoolifyData() {
410-
[ -s /data/coolify/ssh/keys/[email protected] ]
411-
return $?
412-
}
406+
set +e
407+
IS_COOLIFY_VOLUME_EXISTS=$(docker volume ls | grep coolify-db | wc -l)
408+
set -e
413409

414-
generateAuthorizedKeys() {
415-
sed -i "/root@coolify/d" ~/.ssh/authorized_keys
416-
cat /data/coolify/ssh/keys/[email protected] >> ~/.ssh/authorized_keys
417-
rm -f /data/coolify/ssh/keys/[email protected]
418-
}
419-
generateSshKey() {
410+
if [ "$IS_COOLIFY_VOLUME_EXISTS" -eq 0 ]; then
420411
echo " - Generating SSH key."
421-
ssh-keygen -t ed25519 -a 100 -f /data/coolify/ssh/keys/[email protected] -q -N "" -C root@coolify
422-
chown 9999 /data/coolify/ssh/keys/[email protected]
423-
generateAuthorizedKeys
424-
}
425-
426-
syncSshKeys() {
427-
DB_RUNNING=$(docker inspect coolify-db --format '{{ .State.Status }}' 2>/dev/null)
428-
# Check if SSH key exists in Coolify data but not in authorized_keys
429-
if checkSshKeyInCoolifyData && ! checkSshKeyInAuthorizedKeys; then
430-
# Add the existing Coolify SSH key to authorized_keys
431-
cat /data/coolify/ssh/keys/[email protected] >> ~/.ssh/authorized_keys
432-
# Check if SSH key exists in authorized_keys but not in Coolify data
433-
elif checkSshKeyInAuthorizedKeys && ! checkSshKeyInCoolifyData; then
434-
# Ensure Coolify DB is running before proceeding
435-
if [ "$DB_RUNNING" = "running" ]; then
436-
# Retrieve DB user and SSH key from Coolify database
437-
DB_USER=$(docker inspect coolify-db --format '{{ .Config.Env }}' | grep -oP 'POSTGRES_USER=\K[^ ]+')
438-
DB_SSH_KEY=$(docker exec coolify-db psql -U $DB_USER -d coolify -t -c "SELECT \"private_key\" FROM \"private_keys\" WHERE id = 0 AND team_id = 0 LIMIT 1;" -A -t)
439-
440-
if [ -z "$DB_SSH_KEY" ]; then
441-
# If no key found in DB, generate a new one
442-
echo " - SSH key not found in database. Generating new key."
443-
generateSshKey
444-
else
445-
# If key found in DB, save it and update authorized_keys
446-
echo " - SSH key found in database. Saving to file."
447-
echo "$DB_SSH_KEY" > /data/coolify/ssh/keys/[email protected]
448-
chmod 600 /data/coolify/ssh/keys/[email protected]
449-
chown 9999 /data/coolify/ssh/keys/[email protected]
450-
451-
# Generate public key from private key and update authorized_keys
452-
ssh-keygen -y -f /data/coolify/ssh/keys/[email protected] -C root@coolify > /data/coolify/ssh/keys/[email protected]
453-
sed -i "/root@coolify/d" ~/.ssh/authorized_keys
454-
cat /data/coolify/ssh/keys/[email protected] >> ~/.ssh/authorized_keys
455-
rm -f /data/coolify/ssh/keys/[email protected]
456-
chmod 600 ~/.ssh/authorized_keys
457-
fi
458-
fi
459-
# If SSH key doesn't exist in either location
460-
elif ! checkSshKeyInAuthorizedKeys && ! checkSshKeyInCoolifyData; then
461-
# Ensure Coolify DB is running before proceeding
462-
if [ "$DB_RUNNING" = "running" ]; then
463-
# Retrieve DB user and SSH key from Coolify database
464-
DB_USER=$(docker inspect coolify-db --format '{{ .Config.Env }}' | grep -oP 'POSTGRES_USER=\K[^ ]+')
465-
DB_SSH_KEY=$(docker exec coolify-db psql -U $DB_USER -d coolify -t -c "SELECT \"private_key\" FROM \"private_keys\" WHERE id = 0 AND team_id = 0 LIMIT 1;" -A -t)
466-
if [ -z "$DB_SSH_KEY" ]; then
467-
# If no key found in DB, generate a new one
468-
echo " - SSH key not found in database. Generating new key."
469-
generateSshKey
470-
else
471-
# If key found in DB, save it and update authorized_keys
472-
echo " - SSH key found in database. Saving to file."
473-
echo "$DB_SSH_KEY" > /data/coolify/ssh/keys/[email protected]
474-
chmod 600 /data/coolify/ssh/keys/[email protected]
475-
ssh-keygen -y -f /data/coolify/ssh/keys/[email protected] -C root@coolify > /data/coolify/ssh/keys/[email protected]
476-
sed -i "/root@coolify/d" ~/.ssh/authorized_keys
477-
cat /data/coolify/ssh/keys/[email protected] >> ~/.ssh/authorized_keys
478-
fi
479-
else
480-
generateSshKey
481-
fi
482-
fi
483-
}
484-
485-
syncSshKeys || true
412+
ssh-keygen -t ed25519 -a 100 -f /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal -q -N "" -C coolify
413+
chown 9999 /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal
414+
sed -i "/coolify/d" ~/.ssh/authorized_keys
415+
cat /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal.pub >> ~/.ssh/authorized_keys
416+
rm -f /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal.pub
417+
fi
486418

487419
chown -R 9999:root /data/coolify
488420
chmod -R 700 /data/coolify

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.343"
4+
"version": "4.0.0-beta.344"
55
},
66
"nightly": {
7-
"version": "4.0.0-beta.344"
7+
"version": "4.0.0-beta.345"
88
},
99
"helper": {
1010
"version": "1.0.1"

0 commit comments

Comments
 (0)