From 44cf3839cd04fd26d212a06ec536d9d5563550ce Mon Sep 17 00:00:00 2001 From: coder3101 Date: Wed, 15 Jul 2026 00:49:48 +0530 Subject: [PATCH 1/4] Add Dockerfile, docker-compose.yml, and Docker usage instructions --- Dockerfile | 47 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 46 +++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 23 +++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bf79abc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +# ── J-Wash Docker image ────────────────────────────────────────────────────── +# Requires an NVIDIA GPU with CUDA 12.4+ drivers on the host. +# docker build -t j-wash . +# docker run --gpus all -p 8381:8381 -v ./data:/app/data -v ./hf_cache:/app/hf_cache j-wash + +FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04 AS base + +SHELL ["/bin/bash", "-c"] + +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3.11 python3.11-dev python3-pip python3-venv \ + git curl ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get install -y nodejs \ + && rm -rf /var/lib/apt/lists/* + +RUN python3.11 -m venv /venv +ENV PATH="/venv/bin:$PATH" + +WORKDIR /app + +COPY requirements.txt . + +RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cu124 + +RUN git clone https://github.com/anthropics/jacobian-lens vendor/jacobian-lens \ + && pip install -e vendor/jacobian-lens + +RUN pip install --no-cache-dir -r requirements.txt + +COPY ui/package.json ui/package-lock.json ui/ +RUN cd ui && npm ci + +COPY . . + +RUN cd ui && npm run build + +ENV HF_HOME=/app/hf_cache +ENV JWASH_DATA_DIR=/app/data + +EXPOSE 8381 + +VOLUME ["/app/data", "/app/hf_cache", "/app/lenses"] + +ENTRYPOINT ["python3.11", "-X", "utf8", "run.py"] diff --git a/README.md b/README.md index c5a70dc..291c6f9 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ Requirements: - Python 3.11+ - Node.js 18+ +### Native + ```bash git clone https://github.com/extraltodeus/j-wash.git cd j-wash @@ -63,6 +65,50 @@ python -X utf8 run.py Then open **http://localhost:8381**. +### Docker + +Requirements: +- NVIDIA GPU with CUDA 12.4+ drivers +- [Docker](https://docs.docker.com/engine/install/) with the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) + +```bash +# Build the image +docker build -t j-wash . + +# Run (data and HF cache persist on the host) +docker run --gpus all \ + -p 8381:8381 \ + -v ./data:/app/data \ + -v ./hf_cache:/app/hf_cache \ + -v ./lenses:/app/lenses \ + j-wash +``` + +Or use Docker Compose: + +```bash +docker compose up -d +``` + +The container runs `python -X utf8 run.py` by default. Pass additional arguments +(e.g. `--port`, `--data-dir`, `--hf-cache`) after the image name: + +```bash +docker run --gpus all -p 8381:8381 j-wash --port 8381 --data-dir /app/data --hf-cache /app/hf_cache +``` + +Set `HF_TOKEN` for gated/private models: + +```bash +docker run --gpus all -p 8381:8381 -e HF_TOKEN=hf_your_token j-wash +# or with docker-compose: +# HF_TOKEN=hf_your_token docker compose up -d +``` + +> **Note**: The Docker image includes the `jacobian-lens` library and pre-builds the +> React front-end at build time. Model weights are downloaded at runtime into the +> mounted `hf_cache` volume (shared with the host). + ## Running diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7aa7767 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +services: + j-wash: + build: . + image: j-wash + container_name: j-wash + restart: unless-stopped + ports: + - "8381:8381" + volumes: + - ./data:/app/data + - ./hf_cache:/app/hf_cache + - ./lenses:/app/lenses + environment: + - HF_HOME=/app/hf_cache + - JWASH_DATA_DIR=/app/data + - HF_TOKEN=${HF_TOKEN:-} + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [gpu] From 33d5f774596ce3386a9f7aa8ea0835b60d53cb9e Mon Sep 17 00:00:00 2001 From: coder3101 Date: Wed, 15 Jul 2026 00:53:32 +0530 Subject: [PATCH 2/4] Fix Dockerfile: install python3.11-venv --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bf79abc..ec38a59 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04 AS base SHELL ["/bin/bash", "-c"] RUN apt-get update && apt-get install -y --no-install-recommends \ - python3.11 python3.11-dev python3-pip python3-venv \ + python3.11 python3.11-dev python3-pip python3.11-venv \ git curl ca-certificates \ && rm -rf /var/lib/apt/lists/* From ed59ac964bfed2f5307d81a2c7aaa010abc561ea Mon Sep 17 00:00:00 2001 From: coder3101 Date: Wed, 15 Jul 2026 01:07:11 +0530 Subject: [PATCH 3/4] Add --host argument to run.py for binding to 0.0.0.0 --- run.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index a787cac..4a5fd0e 100644 --- a/run.py +++ b/run.py @@ -18,6 +18,10 @@ def main(): "Default: ./data. Give each instance its own when running several " "servers side by side.", ) + parser.add_argument( + "--host", default=None, + help="Bind address (default: 127.0.0.1). Use 0.0.0.0 for Docker.", + ) parser.add_argument( "--port", type=int, default=None, help="HTTP port (default: 8381). Use a distinct port per instance.", @@ -49,7 +53,8 @@ def main(): import uvicorn - uvicorn.run("api.app:app", host=config.HOST, port=args.port or config.PORT, log_level="info") + host = args.host or os.environ.get("JWASH_HOST") or config.HOST + uvicorn.run("api.app:app", host=host, port=args.port or config.PORT, log_level="info") if __name__ == "__main__": From 0db2837f13e3ae8689054a5195e24a560ba96739 Mon Sep 17 00:00:00 2001 From: coder3101 Date: Wed, 15 Jul 2026 01:08:00 +0530 Subject: [PATCH 4/4] Default to --host 0.0.0.0 in Docker and docker-compose --- Dockerfile | 2 +- README.md | 7 ++++--- docker-compose.yml | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ec38a59..e3a44a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,4 +44,4 @@ EXPOSE 8381 VOLUME ["/app/data", "/app/hf_cache", "/app/lenses"] -ENTRYPOINT ["python3.11", "-X", "utf8", "run.py"] +ENTRYPOINT ["python3.11", "-X", "utf8", "run.py", "--host", "0.0.0.0"] diff --git a/README.md b/README.md index 291c6f9..5e69ee6 100644 --- a/README.md +++ b/README.md @@ -90,11 +90,12 @@ Or use Docker Compose: docker compose up -d ``` -The container runs `python -X utf8 run.py` by default. Pass additional arguments -(e.g. `--port`, `--data-dir`, `--hf-cache`) after the image name: +The container binds to `0.0.0.0` by default so the UI is reachable from outside +the container. Pass additional arguments (e.g. `--port`, `--host`) after the image +name: ```bash -docker run --gpus all -p 8381:8381 j-wash --port 8381 --data-dir /app/data --hf-cache /app/hf_cache +docker run --gpus all -p 8381:8381 j-wash --port 8381 --host 0.0.0.0 ``` Set `HF_TOKEN` for gated/private models: diff --git a/docker-compose.yml b/docker-compose.yml index 7aa7767..5eb20fa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: - ./hf_cache:/app/hf_cache - ./lenses:/app/lenses environment: + - JWASH_HOST=0.0.0.0 - HF_HOME=/app/hf_cache - JWASH_DATA_DIR=/app/data - HF_TOKEN=${HF_TOKEN:-}