Skip to content

Commit

Permalink
updated base - log and port UIs
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Sep 12, 2023
1 parent edf20ca commit bd6901f
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 25 deletions.
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ Micromamba environments are particularly useful where several software packages
| Environment | Packages |
| -------------- | ----------------------------------------- |
| `base` | micromamba's base environment |
| `comfyui` | ComfyUI and dependencies |
| `system` | `supervisord`, `openssh` `rclone` |
| `fastapi` | `logtail web UI`, `port redirector web UI` |
| `comfyui` | ComfyUI and dependencies |
| `python_[ver]` | `python` |

If you are extending this image or running an interactive session where additional software is required, you should almost certainly create a new environment first. See below for guidance.
Expand Down Expand Up @@ -274,6 +275,25 @@ Jupyter's official documentation is available at https://jupyter.org/
>[!NOTE]
>_If you have enabled `CF_QUICK_TUNNELS` a secure `https://[random-auto-generated-sub-domain].trycloudflare.com` link will be created. You can find it at `/var/log/supervisor/quicktunnel-jupyter.log`_
### Port Redirector

This is a simple list of links to the web services available inside the container.

The service will bind to port `1111`.

For each service, you will find a direct link and, if you have set `CF_QUICK_TUNNELS=true`, a link to the service via a fast and secure Cloudflare tunnel.

>[!NOTE]
>*This service will not show links to any pre-configured Cloudflare tunnels as the domains are static and already known to the user.*
### Log Viewer

The web based log viewer will start on port `1122`.

It's a very lightweight websocket based stream of the latest updates in `/var/log/logtail.log`.

This service will also be accessible on any other exposed ports until the program designated to that port is ready to use.

### Cloudflared

The Cloudflare tunnel daemon will start if you have provided a token with the `CF_TUNNEL_TOKEN` environment variable.
Expand Down Expand Up @@ -353,10 +373,13 @@ If you are logged into the container you can follow the logs by running `logtail
Some ports need to be exposed for the services to run or for certain features of the provided software to function


| Open Port | Service / Description |
| --------------------- | --------------------- |
| `22` | SSH server |
| `8188` | ComfyUI Interface |
| Open Port | Service / Description |
| --------------------- | ------------------------- |
| `22` | SSH server |
| `1111` | Port redirector web UI |
| `1122` | Log viewer web UI |
| `8188` | ComfyUI Interface |
| `8888` | Jupyter |
| `53682` | Rclone interactive config |

## Pre-Configured Templates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ process_name=%(program_name)s
numprocs=1
directory=/root
priority=1500
autostart=false
autostart=true
startsecs=0
startretries=3
autorestart=unexpected
Expand Down
40 changes: 35 additions & 5 deletions build/COPY_ROOT/opt/ai-dock/bin/supervisor-comfyui.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,53 @@
#!/bin/bash

trap 'kill $(jobs -p)' EXIT
trap cleanup EXIT

function cleanup() {
kill $(jobs -p) > /dev/null 2>&1
rm /run/http_ports/$PORT > /dev/null 2>&1
}

SERVICE="ComfyUI"

if [[ -z $COMFYUI_PORT ]]; then
COMFYUI_PORT=8188
fi

printf "Starting ComfyUI...\n"
PORT=$COMFYUI_PORT
METRICS_PORT=1188
SERVICE_NAME="ComfyUI"

if [[ $CF_QUICK_TUNNELS = "true" ]]; then
cloudflared tunnel --url localhost:${COMFYUI_PORT} > /var/log/supervisor/quicktunnel-comfyui.log 2>&1 &
fi
printf "{\"port\": \"$PORT\", \"metrics_port\": \"$METRICS_PORT\", \"service_name\": \"$SERVICE_NAME\"}" > /run/http_ports/$PORT

PLATFORM_FLAGS=""
if [[ $XPU_TARGET = "CPU" ]]; then
PLATFORM_FLAGS="--cpu"
fi
BASE_FLAGS="--listen 0.0.0.0 --port ${COMFYUI_PORT} --disable-auto-launch"

if [[ -f /run/provisioning_script ]]; then
micromamba run -n fastapi python /opt/ai-dock/fastapi/logviewer/main.py \
-p $COMFYUI_PORT \
-r 5 \
-s ${SERVICE} \
-u comfyui \
-t "Preparing ${SERVICE}" &
fastapi_pid=$!

while [[ -f /run/provisioning_script ]]; do
sleep 1
done

printf "\nStarting %s... " ${SERVICE:-service}
kill $fastapi_pid && \
printf "OK\n"
else
printf "Starting %s...\n" ${SERVICE}
fi

kill -9 $(lsof -t -i:$COMFYUI_PORT) > /dev/null 2>&1 &
wait -n

cd /opt/ComfyUI
micromamba run -n comfyui python main.py \
${PLATFORM_FLAGS} \
Expand Down
16 changes: 2 additions & 14 deletions build/COPY_ROOT/usr/local/share/ai-dock/comfyui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,9 @@
"metadata": {},
"outputs": [],
"source": [
"# Get secure ComfyUI link\n",
"# Get secure UI links\n",
"\n",
"!get-cfqt-comfyui.sh"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "08cbd5a5-0d3f-44d0-a952-cc0d0dd35a2a",
"metadata": {},
"outputs": [],
"source": [
"# Get secure Jupyter link\n",
"\n",
"!get-cfqt-jupyter.sh"
"!cfqt-url.sh -p 1111"
]
}
],
Expand Down
1 change: 1 addition & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ LABEL org.opencontainers.image.description "ComfyUI Stable Diffusion backend and

LABEL maintainer="Rob Ballantyne <[email protected]>"

ENV IMAGE_SLUG="comfyui"

# Copy early so we can use scripts in the build - Changes to these files will invalidate the cache and cause a rebuild.
COPY ./COPY_ROOT/ /
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ services:
ports:
# SSH available on host machine port 2222 to avoid conflict. Change to suit
- ${SSH_PORT_HOST:-2222}:${SSH_PORT:-22}
# redirect to Cloudflare quick tunnel
- ${REDIRECTOR_PORT_HOST}:1111
# Websocket log viewer
- ${LOG_VIEWER_PORT_HOST}:1122
# ComfyUI web interface
- ${COMFYUI_PORT_HOST:-8188}:${COMFYUI_PORT:-8188}
# Jupyter server
Expand Down

0 comments on commit bd6901f

Please sign in to comment.