diff --git a/app/Models/Server.php b/app/Models/Server.php index 337d7d7fa..44746324b 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -326,7 +326,7 @@ respond 404 'loadBalancer' => [ 'servers' => [ 0 => [ - 'url' => 'http://coolify-terminal:6002', + 'url' => 'http://coolify-realtime:6002', ], ], ], @@ -404,7 +404,7 @@ $schema://$host { reverse_proxy coolify-realtime:6001 } handle /terminal/* { - reverse_proxy coolify-terminal:6002 + reverse_proxy coolify-realtime:6002 } reverse_proxy coolify:80 }"; diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 9710e0fae..64eb1d2a4 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -47,21 +47,19 @@ services: - .env ports: - "${FORWARD_SOKETI_PORT:-6001}:6001" + - "6002:6002" + volumes: + - ./docker/soketi-entrypoint/soketi-entrypoint.sh:/soketi-entrypoint.sh + - ./package.json:/terminal/package.json + - ./package-lock.json:/terminal/package-lock.json + - ./terminal-server.js:/terminal/terminal-server.js + - ./storage:/var/www/html/storage + entrypoint: ["/bin/sh", "/soketi-entrypoint.sh"] environment: SOKETI_DEBUG: "false" SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID:-coolify}" SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY:-coolify}" SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}" - terminal: - env_file: - - .env - pull_policy: always - working_dir: /var/www/html - ports: - - "${FORWARD_TERMINAL_PORT:-6002}:6002" - volumes: - - .:/var/www/html:cached - command: sh -c "apk add --no-cache openssh-client && node --watch /var/www/html/terminal-server.js" vite: image: node:alpine pull_policy: always @@ -72,7 +70,7 @@ services: - "${VITE_PORT:-5173}:${VITE_PORT:-5173}" volumes: - .:/var/www/html:cached - command: sh -c "apk add --no-cache make g++ python3 && npm install && npm run dev" + command: sh -c "npm install && npm run dev" networks: - coolify testing-host: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 5f7b5e935..5fc6a9919 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -115,25 +115,21 @@ services: soketi: ports: - "${SOKETI_PORT:-6001}:6001" + - "6002:6002" + volumes: + - ./docker/soketi-entrypoint/soketi-entrypoint.sh:/soketi-entrypoint.sh + - ./package.json:/terminal/package.json + - ./package-lock.json:/terminal/package-lock.json + - ./terminal-server.js:/terminal/terminal-server.js + - ./storage:/var/www/html/storage + entrypoint: ["/bin/sh", "/soketi-entrypoint.sh"] environment: SOKETI_DEBUG: "${SOKETI_DEBUG:-false}" SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID}" SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}" SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}" healthcheck: - test: wget -qO- http://127.0.0.1:6001/ready || exit 1 - interval: 5s - retries: 10 - timeout: 2s - terminal: - working_dir: /var/www/html - ports: - - "${TERMINAL_PORT:-6002}:6002" - volumes: - - .:/var/www/html:cached - command: sh -c "apk add --no-cache openssh-client && node /var/www/html/terminal-server.js" - healthcheck: - test: wget -qO- http://localhost:6002/ready || exit 1 + test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:6001/ready && wget -qO- http://127.0.0.1:6002/ready || exit 1"] interval: 5s retries: 10 timeout: 2s diff --git a/docker-compose.windows.yml b/docker-compose.windows.yml index ab3c7197a..1b800a5d6 100644 --- a/docker-compose.windows.yml +++ b/docker-compose.windows.yml @@ -102,7 +102,7 @@ services: interval: 5s retries: 10 timeout: 2s - soketi: +soketi: image: 'quay.io/soketi/soketi:1.6-16-alpine' pull_policy: always container_name: coolify-realtime @@ -111,34 +111,25 @@ services: - .env ports: - "${SOKETI_PORT:-6001}:6001" + - "6002:6002" + volumes: + - ./docker/soketi-entrypoint/soketi-entrypoint.sh:/soketi-entrypoint.sh + - ./package.json:/terminal/package.json + - ./package-lock.json:/terminal/package-lock.json + - ./terminal-server.js:/terminal/terminal-server.js + - ./storage:/var/www/html/storage + entrypoint: ["/bin/sh", "/soketi-entrypoint.sh"] environment: SOKETI_DEBUG: "${SOKETI_DEBUG:-false}" SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID}" SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY}" SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET}" healthcheck: - test: wget -qO- http://localhost:6001/ready || exit 1 - interval: 5s - retries: 10 - timeout: 2s - terminal: - image: node:alpine - pull_policy: always - container_name: coolify-terminal - restart: always - env_file: - - .env - working_dir: /var/www/html - ports: - - "${TERMINAL_PORT:-6002}:6002" - volumes: - - .:/var/www/html:cached - command: sh -c "apk add --no-cache openssh-client && node /var/www/html/terminal-server.js" - healthcheck: - test: wget -qO- http://localhost:6002/ready || exit 1 + test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:6001/ready && wget -qO- http://127.0.0.1:6002/ready || exit 1"] interval: 5s retries: 10 timeout: 2s + volumes: coolify-db: name: coolify-db diff --git a/docker-compose.yml b/docker-compose.yml index 4f1c03127..8eed44f8c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,12 +28,6 @@ services: restart: always networks: - coolify - terminal: - image: node:alpine - container_name: coolify-terminal - restart: always - networks: - - coolify networks: coolify: name: coolify diff --git a/docker/soketi-entrypoint/soketi-entrypoint.sh b/docker/soketi-entrypoint/soketi-entrypoint.sh new file mode 100644 index 000000000..808e306e7 --- /dev/null +++ b/docker/soketi-entrypoint/soketi-entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Install openssh-client +apk add --no-cache openssh-client make g++ python3 + +cd /terminal + +# Install npm dependencies +npm ci + +# Rebuild node-pty +npm rebuild node-pty --update-binary + +# Function to timestamp logs +timestamp() { + date "+%Y-%m-%d %H:%M:%S" +} + +# Start the terminal server in the background with logging +node --watch /terminal/terminal-server.js > >(while read line; do echo "$(timestamp) [TERMINAL] $line"; done) 2>&1 & +TERMINAL_PID=$! + +# Start the Soketi process in the background with logging +node /app/bin/server.js start > >(while read line; do echo "$(timestamp) [SOKETI] $line"; done) 2>&1 & +SOKETI_PID=$! + +# Function to forward signals to child processes +forward_signal() { + kill -$1 $TERMINAL_PID $SOKETI_PID +} + +# Forward SIGTERM to child processes +trap 'forward_signal TERM' TERM + +# Wait for any process to exit +wait -n + +# Exit with status of process that exited first +exit $? \ No newline at end of file