init
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
*.AppImage
|
||||||
|
data/*
|
||||||
|
* copy*
|
||||||
60
Dockerfile
Normal file
60
Dockerfile
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
ARG baseimage=nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04
|
||||||
|
|
||||||
|
FROM ${baseimage} AS baseimage
|
||||||
|
ENV LANG C.UTF-8
|
||||||
|
ENV LC_ALL C.UTF-8
|
||||||
|
|
||||||
|
|
||||||
|
ENV TZ="Etc/UTC"
|
||||||
|
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
# Build arguments
|
||||||
|
ARG ARG_UID=1000
|
||||||
|
ARG ARG_GID=1000
|
||||||
|
|
||||||
|
RUN <<eot
|
||||||
|
set -eux
|
||||||
|
apt -qy update
|
||||||
|
apt -qy install --no-install-recommends \
|
||||||
|
-o APT::Install-Recommends=false \
|
||||||
|
-o APT::Install-Suggests=false \
|
||||||
|
console-setup tzdata dbus x11-utils x11-xserver-utils libgl1-mesa-glx
|
||||||
|
apt -qy update
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt -qy install --no-install-recommends \
|
||||||
|
-o APT::Install-Recommends=false \
|
||||||
|
-o APT::Install-Suggests=false \
|
||||||
|
libfuse2 kmod fuse libglib2.0-0 libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libgtk-3-0 libgbm1 libasound2 xserver-xorg xvfb x11vnc
|
||||||
|
mkdir -p /root/.vnc && x11vnc -storepasswd test123 /root/.vnc/passwd
|
||||||
|
eot
|
||||||
|
|
||||||
|
ENV DISPLAY=:99
|
||||||
|
|
||||||
|
#########################
|
||||||
|
|
||||||
|
FROM baseimage AS final
|
||||||
|
|
||||||
|
ADD ./LM-Studio* /data/lms/
|
||||||
|
ADD ./http-server-config.json /http-server-config.json
|
||||||
|
|
||||||
|
RUN <<eot
|
||||||
|
set -eux
|
||||||
|
chmod ugo+x /data/lms/*.AppImage
|
||||||
|
/data/lms/*.AppImage --appimage-extract
|
||||||
|
eot
|
||||||
|
|
||||||
|
|
||||||
|
ADD ./docker-entrypoint.sh /usr/local/bin/
|
||||||
|
ADD ./docker-healthcheck.sh /usr/local/bin/
|
||||||
|
|
||||||
|
# Ensure the scripts are executable
|
||||||
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \
|
||||||
|
chmod +x /usr/local/bin/docker-healthcheck.sh
|
||||||
|
# Setup the healthcheck
|
||||||
|
HEALTHCHECK --interval=1m --timeout=10s --start-period=1m \
|
||||||
|
CMD /bin/bash /usr/local/bin/docker-healthcheck.sh || exit 1
|
||||||
|
|
||||||
|
|
||||||
|
# Run the server
|
||||||
|
# CMD ["sh", "-c", "tail -f /dev/null"] # For development: keep container open
|
||||||
|
ENTRYPOINT ["/bin/bash", "/usr/local/bin/docker-entrypoint.sh"]
|
||||||
65
README.md
Normal file
65
README.md
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# LMStudio Docker Deployment
|
||||||
|
|
||||||
|
This repository contains the necessary files to run [LMStudio](https://lmstudio.ai), an application for language model interaction, within a Docker container. The setup includes configuration files for both the entry point script, health check, Docker Compose file, Dockerfile, and HTTP server configuration.
|
||||||
|
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
LMStudio is a tool designed for interacting with language models, providing a seamless experience through a web interface. This setup uses Docker to containerize the application and deployment tools like Docker Compose for easy management of multiple containers.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
Before you begin, ensure that your system meets the following requirements:
|
||||||
|
- [Docker](https://docs.docker.com/get-docker/) installed on your machine.
|
||||||
|
- Docker Compose (usually included with Docker Engine).
|
||||||
|
- A suitable environment to run the LMStudio container (e.g., a Linux server or local machine capable of running Docker containers).
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
1. Clone this repository to your local machine:
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/n0mer1/lmstudio-docker.git LMStudio
|
||||||
|
cd LMStudio
|
||||||
|
```
|
||||||
|
2. Review the `docker-compose.yml` file to ensure it meets your requirements. Adjust any environment variables or paths as necessary.
|
||||||
|
3. Download the LMStudio installer:
|
||||||
|
```bash
|
||||||
|
wget https://installers.lmstudio.ai/linux/x64/0.3.14-5/LM-Studio-0.3.14-5-x64.AppImage
|
||||||
|
```
|
||||||
|
4. Build and run the Docker containers using:
|
||||||
|
```bash
|
||||||
|
docker-compose up -d --build
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Configuration settings are managed via environment variables and configuration files as follows:
|
||||||
|
- **Environment Variables**: Set these in the Docker Compose file or directly in the `.env` file if used.
|
||||||
|
- `CONTEXT_LENGTH`: Defines the context length for model interactions.
|
||||||
|
- `MODEL_PATH`: Path to the specific language model to be loaded.
|
||||||
|
- `MODEL_IDENTIFIER`: Identifier for the loaded model.
|
||||||
|
|
||||||
|
|
||||||
|
## Running the Services
|
||||||
|
To start the services defined in `docker-compose.yml`, use the following command from the project directory:
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
This command will run the containers in detached mode, allowing you to continue using your terminal without interruption.
|
||||||
|
|
||||||
|
To stop the services, use:
|
||||||
|
```bash
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
If you encounter issues during setup or usage:
|
||||||
|
1. Check the logs for errors:
|
||||||
|
```bash
|
||||||
|
docker-compose logs -f lmstudio
|
||||||
|
```
|
||||||
|
2. Ensure all required environment variables are set correctly in the Docker Compose file or `.env` file.
|
||||||
|
3. Verify that the container is running:
|
||||||
|
```bash
|
||||||
|
docker ps
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
Contributions to this project are welcome. Please open an issue for bugs or feature requests and submit a pull request with proposed changes. For major changes, please discuss them in advance.
|
||||||
33
docker-compose.yml
Normal file
33
docker-compose.yml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
networks:
|
||||||
|
homelab_homelabnet:
|
||||||
|
external: true
|
||||||
|
|
||||||
|
services:
|
||||||
|
lmstudio:
|
||||||
|
image: lmstudio:latest
|
||||||
|
container_name: lmstudio
|
||||||
|
restart: unless-stopped
|
||||||
|
build:
|
||||||
|
context: "$HOME/Development/LMStudio"
|
||||||
|
ports:
|
||||||
|
- "1234:1234"
|
||||||
|
volumes:
|
||||||
|
- "$HOME/Development/LMStudio/data:/root/.cache/lm-studio/models"
|
||||||
|
environment:
|
||||||
|
- CONTEXT_LENGTH=${CONTEXT_LENGTH:-131072}
|
||||||
|
- MODEL_PATH=${MODEL_PATH:-Qwen/Qwen2.5-Coder-14B-Instruct-GGUF}
|
||||||
|
- MODEL_IDENTIFIER=${MODEL_IDENTIFIER:-qwen2.5-coder-14b-instruct}
|
||||||
|
# deploy:
|
||||||
|
# resources:
|
||||||
|
# reservations:
|
||||||
|
# devices:
|
||||||
|
# - capabilities: [gpu]
|
||||||
|
command: ["/start_services.sh"]
|
||||||
|
networks:
|
||||||
|
- homelab_homelabnet
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.routers.lmstudio.entrypoints=http"
|
||||||
|
- "traefik.http.routers.lmstudio.rule=Host(`lmstudio.${DOMAIN}`)"
|
||||||
|
- "traefik.http.services.lmstudio.loadbalancer.server.port=1234"
|
||||||
22
docker-entrypoint.sh
Normal file
22
docker-entrypoint.sh
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rm /tmp/.X99-lock
|
||||||
|
Xvfb :99 -screen 0 1920x1080x16 &
|
||||||
|
sleep 2
|
||||||
|
# -----------------------------------
|
||||||
|
echo 'alias lms="~/.cache/lm-studio/bin/lms"' > ~/.bashrc
|
||||||
|
|
||||||
|
/squashfs-root/lm-studio --no-sandbox &
|
||||||
|
sleep 30
|
||||||
|
~/.cache/lm-studio/bin/lms server start --cors &
|
||||||
|
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
# ~/.cache/lm-studio/bin/lms get ${MODEL_PATH}
|
||||||
|
~/.cache/lm-studio/bin/lms load --gpu 0.3 --ttl 3600 --context-length ${CONTEXT_LENGTH:-16384} ${MODEL_IDENTIFIER} &
|
||||||
|
|
||||||
|
sleep 20
|
||||||
|
cp -f /http-server-config.json /root/.cache/lm-studio/.internal/http-server-config.json
|
||||||
|
x11vnc -display :99 -forever -rfbauth /root/.vnc/passwd -quiet -listen 0.0.0.0 -xkb
|
||||||
|
|
||||||
|
/bin/bash
|
||||||
13
docker-healthcheck.sh
Normal file
13
docker-healthcheck.sh
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Send a request to the specified URL
|
||||||
|
response=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:1234/v1)
|
||||||
|
|
||||||
|
# If the HTTP response code is 200 (OK), the server is up
|
||||||
|
if [ "$response" -eq 200 ]; then
|
||||||
|
echo "Server is up"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Server is down"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
8
http-server-config.json
Normal file
8
http-server-config.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"port": 1234,
|
||||||
|
"cors": true,
|
||||||
|
"logSensitiveData": true,
|
||||||
|
"verbose": false,
|
||||||
|
"logLinesLimit": 500,
|
||||||
|
"networkInterface": "0.0.0.0"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user