llama
This commit is contained in:
31
ssh/Dockerfile
Normal file
31
ssh/Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
FROM alpine:3.22
|
||||
|
||||
RUN apk add --no-cache \
|
||||
openssh-server \
|
||||
docker-cli \
|
||||
docker-cli-compose \
|
||||
&& addgroup -g 1001 docker-host \
|
||||
&& adduser -D -s /bin/sh operator \
|
||||
&& adduser operator docker-host \
|
||||
&& passwd -d operator \
|
||||
&& mkdir -p /home/operator/.ssh \
|
||||
&& ssh-keygen -A
|
||||
|
||||
RUN printf '%s\n' \
|
||||
'PasswordAuthentication no' \
|
||||
'KbdInteractiveAuthentication no' \
|
||||
'PubkeyAuthentication yes' \
|
||||
'PermitRootLogin no' \
|
||||
>> /etc/ssh/sshd_config
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
COPY gpuctl /usr/local/bin/gpuctl
|
||||
|
||||
RUN sed -i 's/\r$//' /usr/local/bin/gpuctl \
|
||||
&& chmod +x /entrypoint.sh /usr/local/bin/gpuctl
|
||||
|
||||
RUN chmod +x /entrypoint.sh /usr/local/bin/gpuctl
|
||||
|
||||
EXPOSE 22
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
10
ssh/entrypoint.sh
Normal file
10
ssh/entrypoint.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cp /mounted-authorized-keys /home/operator/.ssh/authorized_keys
|
||||
|
||||
chown -R operator:operator /home/operator/.ssh
|
||||
chmod 700 /home/operator/.ssh
|
||||
chmod 600 /home/operator/.ssh/authorized_keys
|
||||
|
||||
exec /usr/sbin/sshd -D -e
|
||||
138
ssh/gpuctl
Normal file
138
ssh/gpuctl
Normal file
@@ -0,0 +1,138 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
PROJECT_DIR="/project"
|
||||
|
||||
get_host_project_dir() {
|
||||
docker inspect gpu-node-ssh \
|
||||
--format '{{range .Mounts}}{{if eq .Destination "/project"}}{{.Source}}{{end}}{{end}}'
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
|
||||
status)
|
||||
docker ps \
|
||||
--filter "name=gpu-node-" \
|
||||
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
|
||||
;;
|
||||
|
||||
start)
|
||||
case "${2:-}" in
|
||||
|
||||
llama)
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
HOST_PROJECT_DIR="$(get_host_project_dir)"
|
||||
|
||||
if [ -z "$HOST_PROJECT_DIR" ]; then
|
||||
echo "ERROR: cannot determine host project directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Starting llama..."
|
||||
echo "Models: $HOST_PROJECT_DIR/gpu/llama_models"
|
||||
|
||||
LLAMA_MODELS_HOST="$HOST_PROJECT_DIR/gpu/llama_models" \
|
||||
docker compose --profile llama up -d llama
|
||||
|
||||
echo
|
||||
docker ps \
|
||||
--filter "name=gpu-node-llama" \
|
||||
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
|
||||
;;
|
||||
|
||||
comfy)
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
HOST_PROJECT_DIR="$(get_host_project_dir)"
|
||||
|
||||
if [ -z "$HOST_PROJECT_DIR" ]; then
|
||||
echo "ERROR: cannot determine host project directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Starting ComfyUI..."
|
||||
echo "Models: $HOST_PROJECT_DIR/gpu/comfy_models"
|
||||
|
||||
COMFY_MODELS_HOST="$HOST_PROJECT_DIR/gpu/comfy_models" \
|
||||
docker compose --profile comfy up -d comfyui
|
||||
|
||||
echo
|
||||
docker ps \
|
||||
--filter "name=gpu-node-comfyui" \
|
||||
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: gpuctl start {llama|comfy}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
stop)
|
||||
case "${2:-}" in
|
||||
|
||||
llama)
|
||||
docker stop gpu-node-llama
|
||||
;;
|
||||
|
||||
comfy)
|
||||
docker stop gpu-node-comfyui
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: gpuctl stop {llama|comfy}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
restart)
|
||||
case "${2:-}" in
|
||||
|
||||
llama)
|
||||
docker restart gpu-node-llama
|
||||
;;
|
||||
|
||||
comfy)
|
||||
docker restart gpu-node-comfyui
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: gpuctl restart {llama|comfy}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
logs)
|
||||
case "${2:-}" in
|
||||
|
||||
llama)
|
||||
docker logs --tail 100 gpu-node-llama
|
||||
;;
|
||||
|
||||
comfy)
|
||||
docker logs --tail 100 gpu-node-comfyui
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: gpuctl logs {llama|comfy}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage:"
|
||||
echo " gpuctl status"
|
||||
echo " gpuctl start {llama|comfy}"
|
||||
echo " gpuctl stop {llama|comfy}"
|
||||
echo " gpuctl restart {llama|comfy}"
|
||||
echo " gpuctl logs {llama|comfy}"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
Reference in New Issue
Block a user