Skip to content

Latest commit

 

History

History
195 lines (153 loc) · 9.27 KB

README.md

File metadata and controls

195 lines (153 loc) · 9.27 KB

Docker Compose Deployment

This directory contains everything needed to run the Vulnerability Analysis pipeline with Docker Compose.

deploy/
├── docker-compose.yml      # Default stack (NVIDIA-hosted NIMs)
├── docker-compose.nim.yml  # Overlay adding a self-hosted nim-llm service
├── Dockerfile              # vuln-analysis image (build context is the repo root)
├── nginx/                  # nginx caching proxy (nginx-cache) and SSL (nginx-ssl) config
├── 1_Deploy_CVE.ipynb      # Step-by-step deploy walkthrough
└── 2_Customize_CVE.ipynb   # Customizing scans against the deployed service

Prerequisites

  • Docker with the Compose v2 plugin (docker compose version)

  • Both API credentials below (see the top-level README):

    NVIDIA_API_KEY=your-nvidia-api-key
    TAVILY_API_KEY=your-tavily-api-key

    A project-root .env is convenient for local work, but it is not the only option. You may export these variables or inject them through a CI system, notebook environment, orchestrator, or secret manager. Compatible proxies may be selected with NV_BASE_URL and TAVILY_API_BASE_URL, but the two key variables must still contain the credentials expected by those endpoints. Do not commit real credentials. There is no credential-free mode for a complete, uncached pipeline run.

Running

Run all commands from the repo root. The checked-in wrapper always uses this deployment's Compose file, loads the root .env when present, and explicitly selects the project named by DOCKER_COMPOSE_PROJECT_NAME (default vuln_analysis):

# Record the invoking host UID/GID in .env before creating bind-mounted artifacts
bash deploy/configure-host-identity.sh

# Build the application image
bash deploy/compose.sh build vuln-analysis

# Start the stack and wait for the analysis API healthcheck
bash deploy/compose.sh up -d --wait --wait-timeout 300

# Tear it down
bash deploy/compose.sh down

If credentials are already exported or injected into the Compose environment, the wrapper also works without a root .env. Set DOCKER_COMPOSE_PROJECT_NAME in the environment or .env before the first up when multiple deployments share a host, and use the wrapper for every later lifecycle, logs, and exec command. The deployment and customization notebooks are stateful: run each from top to bottom, run the deployment notebook first when using the HTTP examples, and rerun setup/producer cells after a kernel restart before trusting files left under /tmp.

The two application services run as the UID/GID recorded by deploy/configure-host-identity.sh. Their startup preflight verifies that .tmp, .cache, and outputs are writable before Jupyter or the API starts. If an older root-run deployment already created unwritable paths, stop the stack and have the host owner or storage administrator repair their ownership, then rerun the identity helper. On root-squashed NFS, container root cannot repair those paths.

The stack runs two containers from the vuln-analysis image:

Warning

Externally reachable installations must enable OAuth2/JWT bearer authentication and enforce network access controls such as host firewalls, security groups, or an authenticated ingress. Jupyter listens on all container interfaces, but the default Compose host publication is loopback-only and must not be widened without equivalent authentication and network restrictions.

  • vuln-analysis — the interactive JupyterLab environment, published on loopback port 8000 by default. Set VULN_ANALYSIS_JUPYTER_HOST_PORT to choose another host port; legacy WORKFLOW_HOST_JUPYTER_PORT values are intentionally ignored.

  • vuln-analysis-api — the analysis HTTP API, running nat serve as the container's main workload under Tini and published on port 26466 (with the Dask dashboard on 8787). A crash exits the container and restart: always restarts the service. A Docker healthcheck polls /ready, which requires the NAT API, Dask scheduler, and at least one worker. Check the analysis service status with:

    bash deploy/compose.sh ps

    Async job metadata is stored in the job-state volume. When the API starts, persisted jobs in submitted or running are changed to the terminal interrupted state. A one-shot vuln-analysis-job-state-init service gives the configured non-root API user access to that Docker-managed volume; it does not mount or modify the host checkout. bash deploy/compose.sh down preserves this volume. Adding -v removes all project volumes—including job-state, nginx logs, and both nginx proxy caches—so it is a full reset, not the routine application-cache pruning workflow documented in the root README. A returned pipeline with success:false is stored as terminal failure, retains the full PipelineResult in output, and includes a concise error. Synchronous /generate requests return HTTP 422 with that same failed result body; uncaught NAT exceptions use the workflow_error envelope.

    The service overrides NAT's local-cluster defaults with one concurrent async-job worker and a best-effort per-worker memory limit of 40% of detected system/container memory. NAT adds one worker intended for cleanup, so the default is two Dask process workers with approximately 80% of detected memory configured across them. Dask can exceed these limits, so monitor representative jobs; the settings reduce default resource pressure but are not a hard container-memory cap.

    The nginx service has separate LLM and vulnerability-intelligence proxy-cache volumes, each configured with a 20 GiB maximum. These Docker-managed caches are regenerable but are not included in vuln-analysis cache info or cache prune. Inspect Docker storage with docker system df -v. Preserve job-state unless intentionally resetting persisted async-job metadata.

    On a larger host, set VULN_ANALYSIS_MAX_RUNNING_ASYNC_JOBS and VULN_ANALYSIS_DASK_WORKER_MEMORY_LIMIT in the root .env, then recreate the service:

    bash deploy/compose.sh up -d vuln-analysis-api

    See Sizing the local Dask cluster for an illustrative larger-host configuration, the worker/concurrency formulas, non-worker overhead, threaded workers, and external schedulers.

Running the pipeline inside the container

The vuln-analysis-api service hosts the HTTP API. To run one-off commands (nat run, nat eval) or work interactively, open a shell in the JupyterLab container:

bash deploy/compose.sh exec vuln-analysis bash

You land in /workspace (the repo, mounted from the host) with the project's virtual environment at /opt/vuln-analysis-venv already activated. Keeping the container environment outside /workspace prevents Compose from creating, hiding, or changing ownership of the host checkout's .venv. From here you can run any of the pipeline commands from the top-level README — nat run, nat serve, nat eval — exactly as documented, for example:

nat run --config_file=configs/config.yml --input_file=data/examples/pipeline_input.json

Running them in the container routes API calls through the nginx-cache proxy (via NV_BASE_URL/TAVILY_API_BASE_URL), so repeated inference and search requests can be served from cache — faster runs and fewer paid API calls than running the same commands on the host. Tavily's credential-only /usage readiness request is explicitly excluded from the proxy cache. Type exit to leave the shell; the containers keep running.

Self-hosted NIMs

To run an LLM NIM locally instead of using NVIDIA-hosted endpoints, layer in the overlay:

bash deploy/compose.sh -f deploy/docker-compose.nim.yml up -d

This requires NVIDIA GPUs and the NVIDIA Container Toolkit.

SSL proxy (optional)

An nginx-ssl service is defined under the ssl profile. Provide nginx/cert.pem and nginx/key.pem, then start it with --profile ssl.

How paths resolve

The compose files live here, but the Docker build context is the repo root (context: ../) so the Dockerfile can copy the package source, scripts, and notebooks. All other relative paths (nginx/, the ../:/workspace mount, and the ../.env env_file) are resolved relative to this directory. Always invoke Compose from the repo root as shown above so these paths line up. The image-managed Python environment is /opt/vuln-analysis-venv, outside the bind-mounted checkout; local .venv ownership and contents are therefore unaffected by starting the stack.