mirror of
https://github.com/ershisan99/coolify.git
synced 2026-01-01 05:09:23 +00:00
Compare commits
20 Commits
v4.0.0-bet
...
v4.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c3beb6715 | ||
|
|
a807016cab | ||
|
|
2c2173e773 | ||
|
|
9a1c9124ae | ||
|
|
306c4dcbc5 | ||
|
|
3535dbb98f | ||
|
|
84b2af53d8 | ||
|
|
ba70451765 | ||
|
|
f3ec4ca4a3 | ||
|
|
174923de98 | ||
|
|
68ab8dc14c | ||
|
|
b218356f2d | ||
|
|
e83aecebc3 | ||
|
|
0bb1f57ea7 | ||
|
|
d006edc485 | ||
|
|
aa28c99827 | ||
|
|
6bd8583eab | ||
|
|
567bbe9d0b | ||
|
|
59d2c9748a | ||
|
|
bd2e1ad9fe |
@@ -1442,14 +1442,24 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
||||
if ($this->pull_request_id !== 0) {
|
||||
$local_branch = "pull/{$this->pull_request_id}/head";
|
||||
}
|
||||
$private_key = $this->application->privateKey?->getKeyLocation();
|
||||
$private_key = data_get($this->application, 'private_key.private_key');
|
||||
if ($private_key) {
|
||||
$private_key = base64_encode($private_key);
|
||||
$this->execute_remote_command(
|
||||
[
|
||||
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}"),
|
||||
executeInDocker($this->deployment_uuid, 'mkdir -p /root/.ssh'),
|
||||
],
|
||||
[
|
||||
executeInDocker($this->deployment_uuid, "echo '{$private_key}' | base64 -d | tee /root/.ssh/id_rsa > /dev/null"),
|
||||
],
|
||||
[
|
||||
executeInDocker($this->deployment_uuid, 'chmod 600 /root/.ssh/id_rsa'),
|
||||
],
|
||||
[
|
||||
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}"),
|
||||
'hidden' => true,
|
||||
'save' => 'git_commit_sha',
|
||||
],
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->execute_remote_command(
|
||||
|
||||
@@ -9,6 +9,20 @@ use Livewire\Component;
|
||||
|
||||
class Terminal extends Component
|
||||
{
|
||||
public function getListeners()
|
||||
{
|
||||
$teamId = auth()->user()->currentTeam()->id;
|
||||
|
||||
return [
|
||||
"echo-private:team.{$teamId},ApplicationStatusChanged" => 'closeTerminal',
|
||||
];
|
||||
}
|
||||
|
||||
public function closeTerminal()
|
||||
{
|
||||
$this->dispatch('reloadWindow');
|
||||
}
|
||||
|
||||
#[On('send-terminal-command')]
|
||||
public function sendTerminalCommand($isContainer, $identifier, $serverUuid)
|
||||
{
|
||||
|
||||
@@ -505,6 +505,12 @@ function sslip(Server $server)
|
||||
|
||||
return "http://$baseIp.sslip.io";
|
||||
}
|
||||
// ipv6
|
||||
if (str($server->ip)->contains(':')) {
|
||||
$ipv6 = str($server->ip)->replace(':', '-');
|
||||
|
||||
return "http://{$ipv6}.sslip.io";
|
||||
}
|
||||
|
||||
return "http://{$server->ip}.sslip.io";
|
||||
}
|
||||
|
||||
@@ -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.343',
|
||||
'release' => '4.0.0-beta.346',
|
||||
// When left empty or `null` the Laravel environment will be used
|
||||
'environment' => config('app.env'),
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<?php
|
||||
|
||||
return '4.0.0-beta.343';
|
||||
return '4.0.0-beta.346';
|
||||
|
||||
@@ -65,37 +65,39 @@ class ProductionSeeder extends Seeder
|
||||
]);
|
||||
}
|
||||
// Add Coolify host (localhost) as Server if it doesn't exist
|
||||
if (Server::find(0) == null) {
|
||||
$server_details = [
|
||||
'id' => 0,
|
||||
'name' => 'localhost',
|
||||
'description' => "This is the server where Coolify is running on. Don't delete this!",
|
||||
'user' => 'root',
|
||||
'ip' => 'host.docker.internal',
|
||||
'team_id' => 0,
|
||||
'private_key_id' => 0,
|
||||
];
|
||||
$server_details['proxy'] = ServerMetadata::from([
|
||||
'type' => ProxyTypes::TRAEFIK->value,
|
||||
'status' => ProxyStatus::EXITED->value,
|
||||
]);
|
||||
$server = Server::create($server_details);
|
||||
$server->settings->is_reachable = true;
|
||||
$server->settings->is_usable = true;
|
||||
$server->settings->save();
|
||||
} else {
|
||||
$server = Server::find(0);
|
||||
$server->settings->is_reachable = true;
|
||||
$server->settings->is_usable = true;
|
||||
$server->settings->save();
|
||||
}
|
||||
if (StandaloneDocker::find(0) == null) {
|
||||
StandaloneDocker::create([
|
||||
'id' => 0,
|
||||
'name' => 'localhost-coolify',
|
||||
'network' => 'coolify',
|
||||
'server_id' => 0,
|
||||
]);
|
||||
if (! isCloud()) {
|
||||
if (Server::find(0) == null) {
|
||||
$server_details = [
|
||||
'id' => 0,
|
||||
'name' => 'localhost',
|
||||
'description' => "This is the server where Coolify is running on. Don't delete this!",
|
||||
'user' => 'root',
|
||||
'ip' => 'host.docker.internal',
|
||||
'team_id' => 0,
|
||||
'private_key_id' => 0,
|
||||
];
|
||||
$server_details['proxy'] = ServerMetadata::from([
|
||||
'type' => ProxyTypes::TRAEFIK->value,
|
||||
'status' => ProxyStatus::EXITED->value,
|
||||
]);
|
||||
$server = Server::create($server_details);
|
||||
$server->settings->is_reachable = true;
|
||||
$server->settings->is_usable = true;
|
||||
$server->settings->save();
|
||||
} else {
|
||||
$server = Server::find(0);
|
||||
$server->settings->is_reachable = true;
|
||||
$server->settings->is_usable = true;
|
||||
$server->settings->save();
|
||||
}
|
||||
if (StandaloneDocker::find(0) == null) {
|
||||
StandaloneDocker::create([
|
||||
'id' => 0,
|
||||
'name' => 'localhost-coolify',
|
||||
'network' => 'coolify',
|
||||
'server_id' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) {
|
||||
@@ -112,8 +114,8 @@ class ProductionSeeder extends Seeder
|
||||
}
|
||||
} else {
|
||||
if ($coolify_key) {
|
||||
$coolify_key = Storage::disk('ssh-keys')->get($coolify_key);
|
||||
$user = str($coolify_key)->before('@')->after('id.');
|
||||
$coolify_key = Storage::disk('ssh-keys')->get($coolify_key);
|
||||
PrivateKey::create([
|
||||
'id' => 0,
|
||||
'team_id' => 0,
|
||||
|
||||
@@ -68,7 +68,11 @@ wss.on('connection', (ws) => {
|
||||
|
||||
const messageHandlers = {
|
||||
message: (session, data) => session.ptyProcess.write(data),
|
||||
resize: (session, { cols, rows }) => session.ptyProcess.resize(cols, rows),
|
||||
resize: (session, { cols, rows }) => {
|
||||
cols = cols > 0 ? cols : 80;
|
||||
rows = rows > 0 ? rows : 30;
|
||||
session.ptyProcess.resize(cols, rows)
|
||||
},
|
||||
pause: (session) => session.ptyProcess.pause(),
|
||||
resume: (session) => session.ptyProcess.resume(),
|
||||
checkActive: (session, data) => {
|
||||
@@ -140,6 +144,7 @@ async function handleCommand(ws, command, userId) {
|
||||
|
||||
ptyProcess.onData((data) => ws.send(data));
|
||||
|
||||
// when parent closes
|
||||
ptyProcess.onExit(({ exitCode, signal }) => {
|
||||
console.error(`Process exited with code ${exitCode} and signal ${signal}`);
|
||||
userSession.isActive = false;
|
||||
|
||||
@@ -8,7 +8,7 @@ set -o pipefail # Cause a pipeline to return the status of the last command that
|
||||
CDN="https://cdn.coollabs.io/coolify-nightly"
|
||||
DATE=$(date +"%Y%m%d-%H%M%S")
|
||||
|
||||
VERSION="1.5"
|
||||
VERSION="1.6"
|
||||
DOCKER_VERSION="26.0"
|
||||
# TODO: Ask for a user
|
||||
CURRENT_USER=$USER
|
||||
@@ -39,6 +39,11 @@ if [ "$OS_TYPE" = "manjaro" ] || [ "$OS_TYPE" = "manjaro-arm" ]; then
|
||||
OS_TYPE="arch"
|
||||
fi
|
||||
|
||||
# Check if the OS is Asahi Linux, if so, change it to fedora
|
||||
if [ "$OS_TYPE" = "fedora-asahi-remix" ]; then
|
||||
OS_TYPE="fedora"
|
||||
fi
|
||||
|
||||
# Check if the OS is popOS, if so, change it to ubuntu
|
||||
if [ "$OS_TYPE" = "pop" ]; then
|
||||
OS_TYPE="ubuntu"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"coolify": {
|
||||
"v4": {
|
||||
"version": "4.0.0-beta.343"
|
||||
"version": "4.0.0-beta.346"
|
||||
},
|
||||
"nightly": {
|
||||
"version": "4.0.0-beta.344"
|
||||
"version": "4.0.0-beta.347"
|
||||
},
|
||||
"helper": {
|
||||
"version": "1.0.1"
|
||||
|
||||
@@ -5,17 +5,13 @@
|
||||
// app.component("magic-bar", MagicBar);
|
||||
// app.mount("#vue");
|
||||
|
||||
import { Terminal } from '@xterm/xterm';
|
||||
import '@xterm/xterm/css/xterm.css';
|
||||
import { FitAddon } from '@xterm/addon-fit';
|
||||
import { initializeTerminalComponent } from './terminal.js';
|
||||
|
||||
if (!window.term) {
|
||||
window.term = new Terminal({
|
||||
cols: 80,
|
||||
rows: 30,
|
||||
fontFamily: '"Fira Code", courier-new, courier, monospace, "Powerline Extra Symbols"',
|
||||
cursorBlink: true,
|
||||
['livewire:navigated', 'alpine:init'].forEach((event) => {
|
||||
document.addEventListener(event, () => {
|
||||
// tree-shaking
|
||||
if (document.getElementById('terminal-container')) {
|
||||
initializeTerminalComponent()
|
||||
}
|
||||
});
|
||||
window.fitAddon = new FitAddon();
|
||||
window.term.loadAddon(window.fitAddon);
|
||||
}
|
||||
});
|
||||
|
||||
228
resources/js/terminal.js
Normal file
228
resources/js/terminal.js
Normal file
@@ -0,0 +1,228 @@
|
||||
import { Terminal } from '@xterm/xterm';
|
||||
import '@xterm/xterm/css/xterm.css';
|
||||
import { FitAddon } from '@xterm/addon-fit';
|
||||
|
||||
export function initializeTerminalComponent() {
|
||||
function terminalData() {
|
||||
return {
|
||||
fullscreen: false,
|
||||
terminalActive: false,
|
||||
message: '(connection closed)',
|
||||
term: null,
|
||||
fitAddon: null,
|
||||
socket: null,
|
||||
commandBuffer: '',
|
||||
pendingWrites: 0,
|
||||
paused: false,
|
||||
MAX_PENDING_WRITES: 5,
|
||||
keepAliveInterval: null,
|
||||
|
||||
init() {
|
||||
this.setupTerminal();
|
||||
this.initializeWebSocket();
|
||||
this.setupTerminalEventListeners();
|
||||
|
||||
this.$wire.on('send-back-command', (command) => {
|
||||
this.socket.send(JSON.stringify({
|
||||
command: command
|
||||
}));
|
||||
});
|
||||
|
||||
this.keepAliveInterval = setInterval(this.keepAlive.bind(this), 30000);
|
||||
|
||||
this.$watch('terminalActive', (active) => {
|
||||
if (!active && this.keepAliveInterval) {
|
||||
clearInterval(this.keepAliveInterval);
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
if (active) {
|
||||
this.$refs.terminalWrapper.style.display = 'block';
|
||||
this.resizeTerminal();
|
||||
} else {
|
||||
this.$refs.terminalWrapper.style.display = 'none';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
['livewire:navigated', 'beforeunload'].forEach((event) => {
|
||||
document.addEventListener(event, () => {
|
||||
this.checkIfProcessIsRunningAndKillIt();
|
||||
clearInterval(this.keepAliveInterval);
|
||||
}, { once: true });
|
||||
});
|
||||
|
||||
window.onresize = () => {
|
||||
this.resizeTerminal()
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
setupTerminal() {
|
||||
const terminalElement = document.getElementById('terminal');
|
||||
if (terminalElement) {
|
||||
this.term = new Terminal({
|
||||
cols: 80,
|
||||
rows: 30,
|
||||
fontFamily: '"Fira Code", courier-new, courier, monospace, "Powerline Extra Symbols"',
|
||||
cursorBlink: true,
|
||||
});
|
||||
this.fitAddon = new FitAddon();
|
||||
this.term.loadAddon(this.fitAddon);
|
||||
}
|
||||
},
|
||||
|
||||
initializeWebSocket() {
|
||||
if (!this.socket || this.socket.readyState === WebSocket.CLOSED) {
|
||||
const predefined = window.terminalConfig
|
||||
const connectionString = {
|
||||
protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
|
||||
host: window.location.hostname,
|
||||
port: ":6002",
|
||||
path: '/terminal/ws'
|
||||
}
|
||||
if (!window.location.port) {
|
||||
connectionString.port = ''
|
||||
}
|
||||
if (predefined.host) {
|
||||
connectionString.host = predefined.host
|
||||
}
|
||||
if (predefined.port) {
|
||||
connectionString.port = `:${predefined.port}`
|
||||
}
|
||||
if (predefined.protocol) {
|
||||
connectionString.protocol = predefined.protocol
|
||||
}
|
||||
|
||||
const url =
|
||||
`${connectionString.protocol}://${connectionString.host}${connectionString.port}${connectionString.path}`
|
||||
this.socket = new WebSocket(url);
|
||||
|
||||
this.socket.onmessage = this.handleSocketMessage.bind(this);
|
||||
this.socket.onerror = (e) => {
|
||||
console.error('WebSocket error:', e);
|
||||
};
|
||||
this.socket.onclose = () => {
|
||||
console.log('WebSocket connection closed');
|
||||
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
handleSocketMessage(event) {
|
||||
this.message = '(connection closed)';
|
||||
if (event.data === 'pty-ready') {
|
||||
if (!this.term._initialized) {
|
||||
this.term.open(document.getElementById('terminal'));
|
||||
this.term._initialized = true;
|
||||
} else {
|
||||
this.term.reset();
|
||||
}
|
||||
this.terminalActive = true;
|
||||
this.term.focus();
|
||||
document.querySelector('.xterm-viewport').classList.add('scrollbar', 'rounded');
|
||||
this.resizeTerminal();
|
||||
} else if (event.data === 'unprocessable') {
|
||||
if (this.term) this.term.reset();
|
||||
this.terminalActive = false;
|
||||
this.message = '(sorry, something went wrong, please try again)';
|
||||
} else {
|
||||
this.pendingWrites++;
|
||||
this.term.write(event.data, this.flowControlCallback.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
flowControlCallback() {
|
||||
this.pendingWrites--;
|
||||
if (this.pendingWrites > this.MAX_PENDING_WRITES && !this.paused) {
|
||||
this.paused = true;
|
||||
this.socket.send(JSON.stringify({ pause: true }));
|
||||
} else if (this.pendingWrites <= this.MAX_PENDING_WRITES && this.paused) {
|
||||
this.paused = false;
|
||||
this.socket.send(JSON.stringify({ resume: true }));
|
||||
}
|
||||
},
|
||||
|
||||
setupTerminalEventListeners() {
|
||||
if (!this.term) return;
|
||||
|
||||
this.term.onData((data) => {
|
||||
this.socket.send(JSON.stringify({ message: data }));
|
||||
// Handle CTRL + D or exit command
|
||||
if (data === '\x04' || (data === '\r' && this.stripAnsiCommands(this.commandBuffer).trim().includes('exit'))) {
|
||||
this.checkIfProcessIsRunningAndKillIt();
|
||||
setTimeout(() => {
|
||||
this.terminalActive = false;
|
||||
this.term.reset();
|
||||
}, 500);
|
||||
this.commandBuffer = '';
|
||||
} else if (data === '\r') {
|
||||
this.commandBuffer = '';
|
||||
} else {
|
||||
this.commandBuffer += data;
|
||||
}
|
||||
});
|
||||
|
||||
// Copy and paste functionality
|
||||
this.term.attachCustomKeyEventHandler((arg) => {
|
||||
if (arg.ctrlKey && arg.code === "KeyV" && arg.type === "keydown") {
|
||||
navigator.clipboard.readText()
|
||||
.then(text => {
|
||||
this.socket.send(JSON.stringify({ message: text }));
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (arg.ctrlKey && arg.code === "KeyC" && arg.type === "keydown") {
|
||||
const selection = this.term.getSelection();
|
||||
if (selection) {
|
||||
navigator.clipboard.writeText(selection);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
|
||||
stripAnsiCommands(input) {
|
||||
return input.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, '');
|
||||
},
|
||||
|
||||
keepAlive() {
|
||||
if (this.socket && this.socket.readyState === WebSocket.OPEN) {
|
||||
this.socket.send(JSON.stringify({ ping: true }));
|
||||
}
|
||||
},
|
||||
|
||||
checkIfProcessIsRunningAndKillIt() {
|
||||
if (this.socket && this.socket.readyState == WebSocket.OPEN) {
|
||||
this.socket.send(JSON.stringify({ checkActive: 'force' }));
|
||||
}
|
||||
},
|
||||
|
||||
makeFullscreen() {
|
||||
this.fullscreen = !this.fullscreen;
|
||||
this.$nextTick(() => {
|
||||
this.resizeTerminal();
|
||||
});
|
||||
},
|
||||
|
||||
resizeTerminal() {
|
||||
if (!this.terminalActive || !this.term || !this.fitAddon) return;
|
||||
|
||||
this.fitAddon.fit();
|
||||
const height = this.$refs.terminalWrapper.clientHeight;
|
||||
const width = this.$refs.terminalWrapper.clientWidth;
|
||||
const rows = Math.floor(height / this.term._core._renderService._charSizeService.height) - 1;
|
||||
const cols = Math.floor(width / this.term._core._renderService._charSizeService.width) - 1;
|
||||
const termWidth = cols;
|
||||
const termHeight = rows;
|
||||
this.term.resize(termWidth, termHeight);
|
||||
this.socket.send(JSON.stringify({
|
||||
resize: { cols: termWidth, rows: termHeight }
|
||||
}));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
window.Alpine.data('terminalData', terminalData);
|
||||
}
|
||||
@@ -76,7 +76,7 @@
|
||||
@endif
|
||||
@if ($application->fqdn)
|
||||
<span class="flex gap-1 text-xs">{{ Str::limit($application->fqdn, 60) }}
|
||||
<x-modal-input title="Edit Domains">
|
||||
<x-modal-input title="Edit Domains" :closeOutside="false">
|
||||
<x-slot:content>
|
||||
<span class="cursor-pointer">
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
@@ -107,15 +107,14 @@
|
||||
Settings
|
||||
</a>
|
||||
@if (str($application->status)->contains('running'))
|
||||
<x-modal-confirmation
|
||||
title="Confirm Service Application Restart?"
|
||||
buttonTitle="Restart"
|
||||
submitAction="restartApplication({{ $application->id }})"
|
||||
:actions="['The selected service application will be unavailable during the restart.', 'If the service application is currently in use data could be lost.']"
|
||||
:confirmWithText="false"
|
||||
:confirmWithPassword="false"
|
||||
step2ButtonText="Restart Service Container"
|
||||
/>
|
||||
<x-modal-confirmation title="Confirm Service Application Restart?"
|
||||
buttonTitle="Restart"
|
||||
submitAction="restartApplication({{ $application->id }})" :actions="[
|
||||
'The selected service application will be unavailable during the restart.',
|
||||
'If the service application is currently in use data could be lost.',
|
||||
]"
|
||||
:confirmWithText="false" :confirmWithPassword="false"
|
||||
step2ButtonText="Restart Service Container" />
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@@ -155,15 +154,13 @@
|
||||
Settings
|
||||
</a>
|
||||
@if (str($database->status)->contains('running'))
|
||||
<x-modal-confirmation
|
||||
title="Confirm Service Database Restart?"
|
||||
buttonTitle="Restart"
|
||||
submitAction="restartDatabase({{ $database->id }})"
|
||||
:actions="['This service database will be unavailable during the restart.', 'If the service database is currently in use data could be lost.']"
|
||||
:confirmWithText="false"
|
||||
:confirmWithPassword="false"
|
||||
step2ButtonText="Restart Database"
|
||||
/>
|
||||
<x-modal-confirmation title="Confirm Service Database Restart?"
|
||||
buttonTitle="Restart" submitAction="restartDatabase({{ $database->id }})"
|
||||
:actions="[
|
||||
'This service database will be unavailable during the restart.',
|
||||
'If the service database is currently in use data could be lost.',
|
||||
]" :confirmWithText="false" :confirmWithPassword="false"
|
||||
step2ButtonText="Restart Database" />
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@@ -183,7 +180,8 @@
|
||||
lazy />
|
||||
@endforeach
|
||||
@foreach ($databases as $database)
|
||||
<livewire:project.service.storage wire:key="database-{{ $database->id }}" :resource="$database" lazy />
|
||||
<livewire:project.service.storage wire:key="database-{{ $database->id }}" :resource="$database"
|
||||
lazy />
|
||||
@endforeach
|
||||
</div>
|
||||
<div x-cloak x-show="activeTab === 'scheduled-tasks'">
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<x-forms.button type="submit">Connect</x-forms.button>
|
||||
</form>
|
||||
@else
|
||||
<div class="pt-4">No containers are not running.</div>
|
||||
<div class="pt-4">No containers are running.</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div x-data="data()">
|
||||
<div id="terminal-container" x-data="terminalData()">
|
||||
{{-- <div x-show="!terminalActive" class="flex items-center justify-center w-full py-4 mx-auto h-[510px]">
|
||||
<div class="p-1 w-full h-full rounded border dark:bg-coolgray-100 dark:border-coolgray-300">
|
||||
<span class="font-mono text-sm text-gray-500" x-text="message"></span>
|
||||
@@ -22,219 +22,14 @@
|
||||
</g>
|
||||
</svg></button>
|
||||
</div>
|
||||
|
||||
@script
|
||||
<script>
|
||||
const MAX_PENDING_WRITES = 5;
|
||||
let pendingWrites = 0;
|
||||
let paused = false;
|
||||
|
||||
let socket;
|
||||
let commandBuffer = '';
|
||||
|
||||
|
||||
function keepAlive() {
|
||||
if (socket && socket.readyState === WebSocket.OPEN) {
|
||||
socket.send(JSON.stringify({
|
||||
ping: true
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
const keepAliveInterval = setInterval(keepAlive, 30000);
|
||||
|
||||
// Clear the interval when the component is destroyed
|
||||
document.addEventListener('livewire:navigating', () => {
|
||||
clearInterval(keepAliveInterval);
|
||||
});
|
||||
|
||||
function initializeWebSocket() {
|
||||
if (!socket || socket.readyState === WebSocket.CLOSED) {
|
||||
const predefined = {
|
||||
protocol: "{{ env('TERMINAL_PROTOCOL') }}",
|
||||
host: "{{ env('TERMINAL_HOST') }}",
|
||||
port: "{{ env('TERMINAL_PORT') }}"
|
||||
}
|
||||
const connectionString = {
|
||||
protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
|
||||
host: window.location.hostname,
|
||||
port: ":6002",
|
||||
path: '/terminal/ws'
|
||||
}
|
||||
if (!window.location.port) {
|
||||
connectionString.port = ''
|
||||
}
|
||||
if (predefined.host) {
|
||||
connectionString.host = predefined.host
|
||||
}
|
||||
if (predefined.port) {
|
||||
connectionString.port = `:${predefined.port}`
|
||||
}
|
||||
if (predefined.protocol) {
|
||||
connectionString.protocol = predefined.protocol
|
||||
}
|
||||
|
||||
const url =
|
||||
`${connectionString.protocol}://${connectionString.host}${connectionString.port}${connectionString.path}`
|
||||
socket = new WebSocket(url);
|
||||
|
||||
socket.onmessage = handleSocketMessage;
|
||||
socket.onerror = (e) => {
|
||||
console.error('WebSocket error:', e);
|
||||
};
|
||||
socket.onclose = () => {
|
||||
console.log('WebSocket connection closed');
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function handleSocketMessage(event) {
|
||||
$data.message = '(connection closed)';
|
||||
// Initialize Terminal
|
||||
if (event.data === 'pty-ready') {
|
||||
term.open(document.getElementById('terminal'));
|
||||
$data.terminalActive = true;
|
||||
term.reset();
|
||||
term.focus();
|
||||
document.querySelector('.xterm-viewport').classList.add('scrollbar', 'rounded')
|
||||
$data.resizeTerminal()
|
||||
} else if (event.data === 'unprocessable') {
|
||||
term.reset();
|
||||
$data.terminalActive = false;
|
||||
$data.message = '(sorry, something went wrong, please try again)';
|
||||
} else {
|
||||
pendingWrites++;
|
||||
term.write(event.data, flowControlCallback);
|
||||
}
|
||||
}
|
||||
|
||||
function flowControlCallback() {
|
||||
pendingWrites--;
|
||||
if (pendingWrites > MAX_PENDING_WRITES && !paused) {
|
||||
paused = true;
|
||||
socket.send(JSON.stringify({
|
||||
pause: true
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (pendingWrites <= MAX_PENDING_WRITES && paused) {
|
||||
paused = false;
|
||||
socket.send(JSON.stringify({
|
||||
resume: true
|
||||
}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
term.onData((data) => {
|
||||
socket.send(JSON.stringify({
|
||||
message: data
|
||||
}));
|
||||
// Type CTRL + D or exit in the terminal
|
||||
if (data === '\x04' || (data === '\r' && stripAnsiCommands(commandBuffer).trim().includes('exit'))) {
|
||||
checkIfProcessIsRunningAndKillIt();
|
||||
setTimeout(() => {
|
||||
$data.terminalActive = false;
|
||||
term.reset();
|
||||
}, 500);
|
||||
commandBuffer = '';
|
||||
} else if (data === '\r') {
|
||||
commandBuffer = '';
|
||||
} else {
|
||||
commandBuffer += data;
|
||||
}
|
||||
});
|
||||
|
||||
function stripAnsiCommands(input) {
|
||||
return input.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, '');
|
||||
}
|
||||
|
||||
// Copy and paste
|
||||
// Enables ctrl + c and ctrl + v
|
||||
// defaults otherwise to ctrl + insert, shift + insert
|
||||
term.attachCustomKeyEventHandler((arg) => {
|
||||
if (arg.ctrlKey && arg.code === "KeyV" && arg.type === "keydown") {
|
||||
navigator.clipboard.readText()
|
||||
.then(text => {
|
||||
socket.send(JSON.stringify({
|
||||
message: text
|
||||
}));
|
||||
})
|
||||
};
|
||||
|
||||
if (arg.ctrlKey && arg.code === "KeyC" && arg.type === "keydown") {
|
||||
const selection = term.getSelection();
|
||||
if (selection) {
|
||||
navigator.clipboard.writeText(selection);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
$wire.on('send-back-command', function(command) {
|
||||
socket.send(JSON.stringify({
|
||||
command: command
|
||||
}));
|
||||
});
|
||||
|
||||
window.addEventListener('beforeunload', function(e) {
|
||||
checkIfProcessIsRunningAndKillIt();
|
||||
});
|
||||
|
||||
function checkIfProcessIsRunningAndKillIt() {
|
||||
socket.send(JSON.stringify({
|
||||
checkActive: 'force'
|
||||
}));
|
||||
}
|
||||
|
||||
window.onresize = function() {
|
||||
$data.resizeTerminal()
|
||||
};
|
||||
|
||||
Alpine.data('data', () => ({
|
||||
fullscreen: false,
|
||||
terminalActive: false,
|
||||
message: '(connection closed)',
|
||||
init() {
|
||||
this.$watch('terminalActive', (value) => {
|
||||
this.$nextTick(() => {
|
||||
if (value) {
|
||||
$refs.terminalWrapper.style.display = 'block';
|
||||
this.resizeTerminal();
|
||||
} else {
|
||||
$refs.terminalWrapper.style.display = 'none';
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
makeFullscreen() {
|
||||
this.fullscreen = !this.fullscreen;
|
||||
$nextTick(() => {
|
||||
this.resizeTerminal()
|
||||
})
|
||||
},
|
||||
|
||||
resizeTerminal() {
|
||||
if (!this.terminalActive) return;
|
||||
|
||||
fitAddon.fit();
|
||||
const height = $refs.terminalWrapper.clientHeight;
|
||||
const rows = height / term._core._renderService._charSizeService.height - 1;
|
||||
var termWidth = term.cols;
|
||||
var termHeight = parseInt(rows.toString(), 10);
|
||||
term.resize(termWidth, termHeight);
|
||||
socket.send(JSON.stringify({
|
||||
resize: {
|
||||
cols: termWidth,
|
||||
rows: termHeight
|
||||
}
|
||||
}));
|
||||
}
|
||||
}));
|
||||
|
||||
initializeWebSocket();
|
||||
</script>
|
||||
<script>
|
||||
// expose terminal config to the terminal.js file
|
||||
window.terminalConfig = {
|
||||
protocol: "{{ env('TERMINAL_PROTOCOL') }}",
|
||||
host: "{{ env('TERMINAL_HOST') }}",
|
||||
port: "{{ env('TERMINAL_PORT') }}"
|
||||
}
|
||||
</script>
|
||||
@endscript
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,8 @@ DATE=$(date +"%Y%m%d-%H%M%S")
|
||||
|
||||
VERSION="1.6"
|
||||
DOCKER_VERSION="26.0"
|
||||
# TODO: Ask for a user
|
||||
CURRENT_USER=$USER
|
||||
|
||||
mkdir -p /data/coolify/{source,ssh,applications,databases,backups,services,proxy,webhooks-during-maintenance,metrics,logs}
|
||||
mkdir -p /data/coolify/ssh/{keys,mux}
|
||||
@@ -401,88 +403,18 @@ if [ ! -f ~/.ssh/authorized_keys ]; then
|
||||
chmod 600 ~/.ssh/authorized_keys
|
||||
fi
|
||||
|
||||
checkSshKeyInAuthorizedKeys() {
|
||||
grep -qw "root@coolify" ~/.ssh/authorized_keys
|
||||
return $?
|
||||
}
|
||||
set +e
|
||||
IS_COOLIFY_VOLUME_EXISTS=$(docker volume ls | grep coolify-db | wc -l)
|
||||
set -e
|
||||
|
||||
checkSshKeyInCoolifyData() {
|
||||
[ -s /data/coolify/ssh/keys/id.root@host.docker.internal ]
|
||||
return $?
|
||||
}
|
||||
|
||||
generateAuthorizedKeys() {
|
||||
sed -i "/root@coolify/d" ~/.ssh/authorized_keys
|
||||
cat /data/coolify/ssh/keys/id.root@host.docker.internal.pub >> ~/.ssh/authorized_keys
|
||||
rm -f /data/coolify/ssh/keys/id.root@host.docker.internal.pub
|
||||
}
|
||||
generateSshKey() {
|
||||
if [ "$IS_COOLIFY_VOLUME_EXISTS" -eq 0 ]; then
|
||||
echo " - Generating SSH key."
|
||||
ssh-keygen -t ed25519 -a 100 -f /data/coolify/ssh/keys/id.root@host.docker.internal -q -N "" -C root@coolify
|
||||
chown 9999 /data/coolify/ssh/keys/id.root@host.docker.internal
|
||||
generateAuthorizedKeys
|
||||
}
|
||||
|
||||
syncSshKeys() {
|
||||
DB_RUNNING=$(docker inspect coolify-db --format '{{ .State.Status }}' 2>/dev/null)
|
||||
# Check if SSH key exists in Coolify data but not in authorized_keys
|
||||
if checkSshKeyInCoolifyData && ! checkSshKeyInAuthorizedKeys; then
|
||||
# Add the existing Coolify SSH key to authorized_keys
|
||||
cat /data/coolify/ssh/keys/id.root@host.docker.internal.pub >> ~/.ssh/authorized_keys
|
||||
# Check if SSH key exists in authorized_keys but not in Coolify data
|
||||
elif checkSshKeyInAuthorizedKeys && ! checkSshKeyInCoolifyData; then
|
||||
# Ensure Coolify DB is running before proceeding
|
||||
if [ "$DB_RUNNING" = "running" ]; then
|
||||
# Retrieve DB user and SSH key from Coolify database
|
||||
DB_USER=$(docker inspect coolify-db --format '{{ .Config.Env }}' | grep -oP 'POSTGRES_USER=\K[^ ]+')
|
||||
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)
|
||||
|
||||
if [ -z "$DB_SSH_KEY" ]; then
|
||||
# If no key found in DB, generate a new one
|
||||
echo " - SSH key not found in database. Generating new key."
|
||||
generateSshKey
|
||||
else
|
||||
# If key found in DB, save it and update authorized_keys
|
||||
echo " - SSH key found in database. Saving to file."
|
||||
echo "$DB_SSH_KEY" > /data/coolify/ssh/keys/id.root@host.docker.internal
|
||||
chmod 600 /data/coolify/ssh/keys/id.root@host.docker.internal
|
||||
chown 9999 /data/coolify/ssh/keys/id.root@host.docker.internal
|
||||
|
||||
# Generate public key from private key and update authorized_keys
|
||||
ssh-keygen -y -f /data/coolify/ssh/keys/id.root@host.docker.internal -C root@coolify > /data/coolify/ssh/keys/id.root@host.docker.internal.pub
|
||||
sed -i "/root@coolify/d" ~/.ssh/authorized_keys
|
||||
cat /data/coolify/ssh/keys/id.root@host.docker.internal.pub >> ~/.ssh/authorized_keys
|
||||
rm -f /data/coolify/ssh/keys/id.root@host.docker.internal.pub
|
||||
chmod 600 ~/.ssh/authorized_keys
|
||||
fi
|
||||
fi
|
||||
# If SSH key doesn't exist in either location
|
||||
elif ! checkSshKeyInAuthorizedKeys && ! checkSshKeyInCoolifyData; then
|
||||
# Ensure Coolify DB is running before proceeding
|
||||
if [ "$DB_RUNNING" = "running" ]; then
|
||||
# Retrieve DB user and SSH key from Coolify database
|
||||
DB_USER=$(docker inspect coolify-db --format '{{ .Config.Env }}' | grep -oP 'POSTGRES_USER=\K[^ ]+')
|
||||
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)
|
||||
if [ -z "$DB_SSH_KEY" ]; then
|
||||
# If no key found in DB, generate a new one
|
||||
echo " - SSH key not found in database. Generating new key."
|
||||
generateSshKey
|
||||
else
|
||||
# If key found in DB, save it and update authorized_keys
|
||||
echo " - SSH key found in database. Saving to file."
|
||||
echo "$DB_SSH_KEY" > /data/coolify/ssh/keys/id.root@host.docker.internal
|
||||
chmod 600 /data/coolify/ssh/keys/id.root@host.docker.internal
|
||||
ssh-keygen -y -f /data/coolify/ssh/keys/id.root@host.docker.internal -C root@coolify > /data/coolify/ssh/keys/id.root@host.docker.internal.pub
|
||||
sed -i "/root@coolify/d" ~/.ssh/authorized_keys
|
||||
cat /data/coolify/ssh/keys/id.root@host.docker.internal.pub >> ~/.ssh/authorized_keys
|
||||
fi
|
||||
else
|
||||
generateSshKey
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
syncSshKeys || true
|
||||
ssh-keygen -t ed25519 -a 100 -f /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal -q -N "" -C coolify
|
||||
chown 9999 /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal
|
||||
sed -i "/coolify/d" ~/.ssh/authorized_keys
|
||||
cat /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal.pub >> ~/.ssh/authorized_keys
|
||||
rm -f /data/coolify/ssh/keys/id.$CURRENT_USER@host.docker.internal.pub
|
||||
fi
|
||||
|
||||
chown -R 9999:root /data/coolify
|
||||
chmod -R 700 /data/coolify
|
||||
@@ -492,7 +424,7 @@ echo -e " - It could take a while based on your server's performance, network sp
|
||||
echo -e " - Please wait."
|
||||
getAJoke
|
||||
|
||||
bash /data/coolify/source/upgrade.sh "${LATEST_VERSION:-latest}" "${LATEST_HELPER_VERSION:-latest}" >/dev/null 2>&1
|
||||
bash /data/coolify/source/upgrade.sh "${LATEST_VERSION:-latest}" "${LATEST_HELPER_VERSION:-latest}"
|
||||
echo " - Coolify installed successfully."
|
||||
rm -f $ENV_FILE-$DATE
|
||||
|
||||
|
||||
@@ -3,21 +3,30 @@
|
||||
# slogan:
|
||||
# tags:
|
||||
# logo:
|
||||
# port: 5000
|
||||
# port: 4200
|
||||
|
||||
services:
|
||||
postiz:
|
||||
image: "ghcr.io/gitroomhq/postiz-app:latest"
|
||||
environment:
|
||||
- SERVICE_FQDN_POSTIZ_5000
|
||||
- SERVICE_FQDN_POSTIZ_4200
|
||||
- MAIN_URL=${SERVICE_FQDN_POSTIZ}
|
||||
- FRONTEND_URL=${SERVICE_FQDN_POSTIZ}
|
||||
- NEXT_PUBLIC_BACKEND_URL=${SERVICE_FQDN_POSTIZ_3000}
|
||||
- NEXT_PUBLIC_BACKEND_URL=${SERVICE_FQDN_POSTIZAPI_3000}
|
||||
- JWT_SECRET=${SERVICE_REALBASE64_JWTSECRET}
|
||||
- DATABASE_URL=postgresql://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@postgres:5432/${POSTGRES_DB:-postiz}?schema=public
|
||||
- REDIS_URL=redis://redis:6379
|
||||
- BACKEND_INTERNAL_URL=${SERVICE_FQDN_POSTIZ}
|
||||
- BACKEND_INTERNAL_URL=http://localhost:3000/
|
||||
- IS_GENERAL=true
|
||||
- CLOUDFLARE_ACCOUNT_ID=${CLOUDFLARE_ACCOUNT_ID}
|
||||
- CLOUDFLARE_ACCESS_KEY=${CLOUDFLARE_ACCESS_KEY}
|
||||
- CLOUDFLARE_SECRET_ACCESS_KEY=${CLOUDFLARE_SECRET_ACCESS_KEY}
|
||||
- CLOUDFLARE_BUCKETNAME=${CLOUDFLARE_BUCKETNAME}
|
||||
- CLOUDFLARE_BUCKET_URL=${CLOUDFLARE_BUCKET_URL}
|
||||
- CLOUDFLARE_REGION=${CLOUDFLARE_REGION}
|
||||
- RESEND_API_KEY=${RESEND_API_KEY}
|
||||
- EMAIL_FROM_ADDRESS=${EMAIL_FROM_ADDRESS}
|
||||
- EMAIL_FROM_NAME=${EMAIL_FROM_NAME}
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
||||
@@ -8,7 +8,7 @@ services:
|
||||
uptime-kuma:
|
||||
image: louislam/uptime-kuma:1
|
||||
environment:
|
||||
- SERVICE_FQDN_UPTIME-KUMA_3001
|
||||
- SERVICE_FQDN_UPTIMEKUMA_3001
|
||||
volumes:
|
||||
- uptime-kuma:/app/data
|
||||
healthcheck:
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"coolify": {
|
||||
"v4": {
|
||||
"version": "4.0.0-beta.343"
|
||||
"version": "4.0.0-beta.346"
|
||||
},
|
||||
"nightly": {
|
||||
"version": "4.0.0-beta.344"
|
||||
"version": "4.0.0-beta.347"
|
||||
},
|
||||
"helper": {
|
||||
"version": "1.0.1"
|
||||
|
||||
Reference in New Issue
Block a user