removed extra container and added new process to soketi container

This commit is contained in:
Luan Estradioto
2024-08-15 20:52:50 -03:00
parent 548fc21e40
commit 2b8c9920d8
6 changed files with 70 additions and 52 deletions

View File

@@ -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
}";

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 $?