Skip to content

Commit

Permalink
removed extra container and added new process to soketi container
Browse files Browse the repository at this point in the history
  • Loading branch information
LEstradioto committed Aug 15, 2024
1 parent 548fc21 commit 2b8c992
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 52 deletions.
4 changes: 2 additions & 2 deletions app/Models/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public function setupDynamicProxyConfiguration()
'loadBalancer' => [
'servers' => [
0 => [
'url' => 'http://coolify-terminal:6002',
'url' => 'http://coolify-realtime:6002',
],
],
],
Expand Down Expand Up @@ -404,7 +404,7 @@ public function setupDynamicProxyConfiguration()
reverse_proxy coolify-realtime:6001
}
handle /terminal/* {
reverse_proxy coolify-terminal:6002
reverse_proxy coolify-realtime:6002
}
reverse_proxy coolify:80
}";
Expand Down
20 changes: 9 additions & 11 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
22 changes: 9 additions & 13 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 11 additions & 20 deletions docker-compose.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 0 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions docker/soketi-entrypoint/soketi-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 $?

0 comments on commit 2b8c992

Please sign in to comment.