From 1fbbf36ba0658357860a64d573e1dfca47f0fe06 Mon Sep 17 00:00:00 2001 From: Code Arranger <80373433+codearranger@users.noreply.github.com> Date: Wed, 2 Oct 2024 08:28:58 -0700 Subject: [PATCH] Dockerized (#99) * Dockerized * Update README.md --- README.md | 8 ++++++++ client/Dockerfile | 21 +++++++++++++++++++++ docker-compose.yml | 40 ++++++++++++++++++++++++++++++++++++++++ moshi/Dockerfile | 24 ++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 client/Dockerfile create mode 100644 docker-compose.yml create mode 100644 moshi/Dockerfile diff --git a/README.md b/README.md index 12d14c1..809b70b 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,14 @@ cargo run --bin moshi-cli -r -- tui --host localhost python -m moshi.client ``` +### Docker Compose (CUDA only) + +```bash +docker compose up +``` + +* Requires [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) + ### WebUI The web UI can be built from this repo via the diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..87a2d93 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,21 @@ +FROM node:20 + +WORKDIR /app + +COPY . /app + +RUN npm install + +RUN npm run build + +# Install OpenSSL +RUN apt-get update && apt-get install -y openssl + +# Generate self-signed SSL certificate +RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ + -keyout /app/key.pem -out /app/cert.pem \ + -subj "/C=US/ST=State/L=City/O=Organization/CN=localhost" + +EXPOSE 5173 + +CMD ["npm", "run", "dev"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d9e00bd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: "3.8" + +name: moshi + +services: + + moshi: + build: + context: ./moshi + expose: + - 8998/tcp + restart: unless-stopped + volumes: + - hf-cache:/root/.cache/huggingface + environment: + #- HF_REPO=kyutai/moshika-pytorch-bf16 + - HF_REPO=kyutai/moshiko-pytorch-bf16 + deploy: + resources: + reservations: + devices: + - driver: nvidia + capabilities: [gpu] + count: all + + tunnel: + image: cloudflare/cloudflared:latest + pull_policy: always + restart: unless-stopped + expose: + - 43337/tcp + environment: + TUNNEL_URL: http://moshi:8998 + TUNNEL_METRICS: 0.0.0.0:43337 + command: tunnel --no-autoupdate + depends_on: + - moshi + +volumes: + hf-cache: diff --git a/moshi/Dockerfile b/moshi/Dockerfile new file mode 100644 index 0000000..f18523a --- /dev/null +++ b/moshi/Dockerfile @@ -0,0 +1,24 @@ +# Use an official Python runtime as a parent image +FROM python:3.10 + +# Set the working directory in the container +WORKDIR /app + +# Copy the current directory contents into the container at /app +COPY . /app + +# Install any needed packages specified in requirements.txt +# Assuming you have a requirements.txt file in the moshi directory +RUN pip install --no-cache-dir -r requirements.txt + +# Install Moshi and gradio +RUN pip install --no-cache-dir moshi gradio + +# Expose the port used by the server +EXPOSE 8998 + +# Set environment variable for the model (with a default value) +ENV HF_REPO=kyutai/moshiko-pytorch-bf16 + +# Run the server when the container launches +CMD python -m moshi.server --gradio-tunnel --hf-repo $HF_REPO