8000 feat(install): run Lens in a microsandbox microVM as an alternative to Docker by adeelahmad · Pull Request #255 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(install): run Lens in a microsandbox microVM as an alternative to Docker - #255

Merged
adeelahmad merged 4 commits into
mainfrom
claude/project-thread-017a05
Oct 10, 2026
Merged

adeelahmad merged 4 commits into
mainfrom
claude/project-thread-017a05

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: the one-line install always ran Lens in Docker.

After: on a first install where microsandbox can run (Linux with KVM, or a Mac with Apple silicon), the installer asks whether to use Docker (still the default) or a microsandbox microVM, which needs no Docker. LENS_BACKEND=microsandbox picks it without the question. The choice is saved in .env, so running the line again keeps it. Existing Docker installs stay on Docker.

How: microsandbox can't build images or connect sandboxes by name, so Lens runs as one sandbox started from python:3.12-slim-bookworm. Inside it, microsandbox/run.sh installs the same system packages as the backend image and fetches SurrealDB 3.2.4, rclone, Node 22 and uv. It builds the backend and web app from the code (mounted read-only), rebuilding only when the code changes. Then it runs SurrealDB, the API, the worker and the web app, and restarts any of them that stops. Data and builds go in the named volume lens-data. The sandbox's network allows the internet, the LAN and the host (host.docker.internal still points at the host's model servers). It publishes the same ports Docker does. A systemd unit (Linux) or a LaunchAgent (Mac) brings the sandbox back after a reboot.

Not yet: Matterbridge, Fedora and OpenSearch in the sandbox; prebuilt images; moving an existing Docker install. These are listed in docs/microsandbox.md.

Motivation and Context

Adeel asked for microsandbox as an install-time alternative to Docker.

Steps to reproduce (if appropriate):

curl -fsSL .../install.sh | LENS_BACKEND=microsandbox sh on a KVM host. CI adds a job, "One-line install in a microsandbox", on a GitHub-hosted runner with KVM. I ran run.sh in a stand-in container (same image, same mounts). It installed and built, the setup page answered, and stop and start were clean, with the database stopped last.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VvAGWoQxiwkGkk374pvkSh


Generated by Claude Code

…o Docker

install.sh asks on a first install (where KVM or Apple silicon is there) whether to run
Lens in Docker, the default, or in one microsandbox microVM; LENS_BACKEND chooses without
asking and is kept in .env. microsandbox/run.sh sets up and runs SurrealDB, the API, the
worker and the web app inside the sandbox from the stock Python image. A CI job runs the
one-line install in a microsandbox on a KVM runner.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VvAGWoQxiwkGkk374pvkSh
@adeelahmad adeelahmad self-assigned this Oct 10, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VvAGWoQxiwkGkk374pvkSh
Copy link
Copy Markdown
Owner Author

FastAPI (SurrealDB server) failed at one test: tests/api/test_sensors.py::test_hub_takes_devices_in_and_organises_them. The assertion that failed checks that the MQTT and syslog listeners are running. That test passed on the other runs, and this PR changes no backend code (it only touches install.sh, microsandbox/, docs and the install workflow). So this failure doesn't come from this PR. No fix exists for it yet. I'm re-running the failed job once.


Generated by Claude Code

…picked

With port 0, UDP chose a free port and TCP then had to bind the same number; when
something already held it on TCP the listener failed to start, which made
test_hub_takes_devices_in_and_organises_them fail now and then.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VvAGWoQxiwkGkk374pvkSh
…cached in its volume

A sandbox started again with msb restart or msb start boots without running Lens, so the
second install never answered. install.sh now writes .lens-sandbox, the command that
replaces the sandbox, runs it, and starts it at boot; run.sh keeps the downloaded packages
in the volume, so a fresh sandbox is up in about half a minute.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VvAGWoQxiwkGkk374pvkSh
@adeelahmad
adeelahmad marked this pull request as ready for review October 10, 2026 14:16
@adeelahmad
adeelahmad merged commit 3ceb032 into main Oct 10, 2026
9 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-017a05 branch October 10, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0