diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..0f065f4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,25 @@ +{ + "name": "smfs", + "build": { + "context": "..", + "dockerfile": "../Dockerfile" + }, + "runArgs": [ + "--device", + "/dev/fuse", + "--cap-add", + "SYS_ADMIN" + ], + "overrideCommand": true, + "remoteEnv": { + "SUPERMEMORY_API_KEY": "${localEnv:SUPERMEMORY_API_KEY}", + "SUPERMEMORY_API_URL": "${localEnv:SUPERMEMORY_API_URL}" + }, + "customizations": { + "vscode": { + "extensions": [ + "rust-lang.rust-analyzer" + ] + } + } +} diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..953c608 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +.git/ +.devcontainer/ +target/ + +bash/node_modules/ +bash/.turbo/ +bash/dist/ +bash/coverage/ + +bash-py/.venv/ +bash-py/__pycache__/ +bash-py/.pytest_cache/ +bash-py/dist/ +bash-py/build/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e687683 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM rust:1.80-slim AS builder + +WORKDIR /src +ENV RUSTUP_TOOLCHAIN=1.80.0 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + pkg-config \ + libssl-dev \ + && rm -rf /var/lib/apt/lists/* + +COPY . . + +RUN cargo build --release --bin smfs + +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + fuse3 \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /src/target/release/smfs /usr/local/bin/smfs + +ENTRYPOINT ["smfs"] +CMD ["--help"] diff --git a/README.md b/README.md index a1adf0d..8000bd5 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Two access flows depending on the runtime: - [Semantic search](#semantic-search) - [`bash/` virtual bash tool](#bash-virtual-bash-tool) - [Build from source](#build-from-source) +- [Docker and devcontainers](#docker-and-devcontainers) - [License](#license) ## Install @@ -152,6 +153,63 @@ cargo build --release Requires Rust 1.80 or newer. +## Docker and devcontainers + +### Run smfs in Docker + +Build the development image from this checkout: + +```sh +docker build -t smfs:dev . +docker run --rm smfs:dev --help +``` + +Mount a Supermemory container inside Docker with FUSE enabled: + +```sh +docker run --rm -it \ + --device /dev/fuse \ + --cap-add SYS_ADMIN \ + -e SUPERMEMORY_API_KEY="$SUPERMEMORY_API_KEY" \ + smfs:dev mount agent_memory --path /mnt/memory +``` + +The release Dockerfile uses the same installer as the shell quickstart: + +```sh +docker build -t smfs:release -f docker/Dockerfile.release . +``` + +When an official image is published, the same run flags apply: + +```sh +docker run --rm -it \ + --device /dev/fuse \ + --cap-add SYS_ADMIN \ + -e SUPERMEMORY_API_KEY="$SUPERMEMORY_API_KEY" \ + ghcr.io/supermemoryai/smfs:latest mount agent_memory --path /mnt/memory +``` + +### Use smfs inside a devcontainer + +Open this repository in VS Code or Cursor and choose "Reopen in Container". +The devcontainer builds the root `Dockerfile`, passes through `SUPERMEMORY_API_KEY` +and `SUPERMEMORY_API_URL`, and starts with `smfs` on `PATH`. + +### FUSE requirements + +Docker runs Linux containers, so smfs uses the FUSE backend in Docker. The NFS +backend is for macOS hosts and is not used inside Linux containers. + +FUSE needs access to `/dev/fuse` and the `SYS_ADMIN` capability: + +```sh +--device /dev/fuse --cap-add SYS_ADMIN +``` + +If your Docker environment does not expose `/dev/fuse`, use a Linux host or a +container runtime that supports FUSE devices. + ## License MIT. See [`LICENSE`](LICENSE). diff --git a/docker/Dockerfile.release b/docker/Dockerfile.release new file mode 100644 index 0000000..c8bac45 --- /dev/null +++ b/docker/Dockerfile.release @@ -0,0 +1,14 @@ +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + fuse3 \ + && rm -rf /var/lib/apt/lists/* + +ARG SMFS_VERSION=latest + +RUN curl -fsSL https://smfs.ai/install | SMFS_INSTALL_DIR=/usr/local/bin bash -s -- "${SMFS_VERSION}" + +ENTRYPOINT ["smfs"] +CMD ["--help"]