From 0e68c8c17706f07e55dfacae08b64a157e6d44d9 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Oct 2026 12:29:38 +0000 Subject: [PATCH 1/4] Cloudron package: install Lens on your own Cloudron CloudronManifest.json, Dockerfile.cloudron and cloudron/ make the repository a Cloudron package. One app runs SurrealDB, the API, a job worker and the web app under supervisord; secrets are made on first start in /app/data, mail goes through the sendmail addon, and the database is exported every six hours so backups hold a consistent copy. A workflow builds the image and can push it to GHCR for community-app publishing. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01NdWJn5kdhHYz3mjiuQ2mVU --- .dockerignore | 23 ++++++++++ .github/workflows/cloudron.yml | 52 ++++++++++++++++++++++ CHANGELOG.md | 11 +++++ CloudronManifest.json | 30 +++++++++++++ Dockerfile.cloudron | 64 ++++++++++++++++++++++++++ cloudron/CHANGELOG | 2 + cloudron/DESCRIPTION.md | 17 +++++++ cloudron/POSTINSTALL.md | 5 +++ cloudron/README.md | 79 +++++++++++++++++++++++++++++++++ cloudron/archive.yaml | 13 ++++++ cloudron/export-db.sh | 21 +++++++++ cloudron/logo.png | Bin 0 -> 13787 bytes cloudron/start.sh | 49 ++++++++++++++++++++ cloudron/supervisord.conf | 74 ++++++++++++++++++++++++++++++ docs/deployment.md | 7 +++ 15 files changed, 447 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/cloudron.yml create mode 100644 CloudronManifest.json create mode 100644 Dockerfile.cloudron create mode 100644 cloudron/CHANGELOG create mode 100644 cloudron/DESCRIPTION.md create mode 100644 cloudron/POSTINSTALL.md create mode 100644 cloudron/README.md create mode 100644 cloudron/archive.yaml create mode 100644 cloudron/export-db.sh create mode 100644 cloudron/logo.png create mode 100644 cloudron/start.sh create mode 100644 cloudron/supervisord.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..99e293fc0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +# Build context of Dockerfile.cloudron (and the source Cloudron uploads on `cloudron install`) +.git +.github +**/node_modules +**/.next +**/.next-* +**/.venv +**/__pycache__ +**/.pytest_cache +**/.ruff_cache +**/.mypy_cache +**/.env +**/.env.* +!**/.env.example +fastapi_backend/archive-data +fastapi_backend/archive.yaml +fastapi_backend/tests +fastapi_backend/coverage.xml +nextjs-frontend/__tests__ +local-audio +local-shared-data +docs +site diff --git a/.github/workflows/cloudron.yml b/.github/workflows/cloudron.yml new file mode 100644 index 000000000..28921242d --- /dev/null +++ b/.github/workflows/cloudron.yml @@ -0,0 +1,52 @@ +name: Cloudron image + +# Builds the Cloudron package (Dockerfile.cloudron) when it changes; run it by hand to push the image to GHCR for +# `cloudron install --image` or `cloudron versions add` (cloudron/README.md). +on: + pull_request: + paths: [Dockerfile.cloudron, CloudronManifest.json, cloudron/**, .dockerignore] + workflow_dispatch: + inputs: + push: + description: "Push to ghcr.io//lens-cloudron" + type: boolean + default: true + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - name: Image name and tag (the manifest's version) + id: meta + run: | + echo "image=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/lens-cloudron" >> "$GITHUB_OUTPUT" + echo "version=$(jq -r .version CloudronManifest.json)" >> "$GITHUB_OUTPUT" + + - uses: docker/setup-buildx-action@v3 + + - if: github.event_name == 'workflow_dispatch' && inputs.push + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile.cloudron + push: ${{ github.event_name == 'workflow_dispatch' && inputs.push }} + tags: ${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.version }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Summary + if: github.event_name == 'workflow_dispatch' && inputs.push + run: | + echo "Pushed \`${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.version }}\`." >> "$GITHUB_STEP_SUMMARY" + echo "Make the package public on GitHub so Cloudron can pull it." >> "$GITHUB_STEP_SUMMARY" diff --git a/CHANGELOG.md b/CHANGELOG.md index ddf835383..efc7e09d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version ## Unreleased +- **Runs on Cloudron.** The repository is now a Cloudron package (`CloudronManifest.json`, `Dockerfile.cloudron`, + `cloudron/`): `cloudron install --location lens -f Dockerfile.cloudron` from a checkout installs Lens on your own + Cloudron, which builds the image itself (cloudron/README.md). + - One app runs SurrealDB, the API, a job worker and the web app; secrets are made on first start and kept in + `/app/data`, password-reset mail goes through Cloudron's mail server, and the first-admin setup code is in + the app's logs. + - The database is exported to `/app/data/backup/lens.surql` every six hours, so Cloudron's backups always hold + a consistent copy alongside the live files. + - It can also be published as a community app (`cloudron versions add`), with the image built and pushed to + GHCR by the new "Cloudron image" workflow. + - **Fix: Chat answers no longer break off with "The answer stopped before it finished".** With some model servers an answer ended mid-stream with nothing saved, so the question sat unanswered in the conversation. Now each one ends in an answer, or an error that's shown and saved with the conversation. diff --git a/CloudronManifest.json b/CloudronManifest.json new file mode 100644 index 000000000..fa73f2384 --- /dev/null +++ b/CloudronManifest.json @@ -0,0 +1,30 @@ +{ + "id": "net.adeelahmad.lens", + "title": "Lens", + "author": "Adeel Ahmad", + "tagline": "An archive for recorded speech and video", + "description": "file://cloudron/DESCRIPTION.md", + "changelog": "file://cloudron/CHANGELOG", + "postInstallMessage": "file://cloudron/POSTINSTALL.md", + "version": "0.3.0", + "upstreamVersion": "0.3.0", + "website": "https://github.com/adeelahmad/lense", + "packagerName": "Adeel Ahmad", + "packagerUrl": "https://github.com/adeelahmad", + "documentationUrl": "https://github.com/adeelahmad/lense/tree/main/docs", + "icon": "file://cloudron/logo.png", + "iconUrl": "https://raw.githubusercontent.com/adeelahmad/lense/main/cloudron/logo.png", + "mediaLinks": [ + "https://raw.githubusercontent.com/adeelahmad/lense/main/cloudron/logo.png" + ], + "tags": ["media", "productivity"], + "healthCheckPath": "/api/v1/auth/status", + "httpPort": 3000, + "addons": { + "localstorage": {}, + "sendmail": {} + }, + "memoryLimit": 3221225472, + "minBoxVersion": "9.1.0", + "manifestVersion": 2 +} diff --git a/Dockerfile.cloudron b/Dockerfile.cloudron new file mode 100644 index 000000000..a4df2eb8c --- /dev/null +++ b/Dockerfile.cloudron @@ -0,0 +1,64 @@ +# Lens as one Cloudron app: SurrealDB, the API, a job worker and the Next.js web app in one container, run by +# supervisord. Only the web app (port 3000) is public; it proxies the API's paths (lib/api/backend-proxy.ts). +# Build and install: see cloudron/README.md. +# --build-arg EXTRAS="sensevoice voices" optional backend extras, as in fastapi_backend/Dockerfile +# --build-arg FULL=true LibreOffice, Chromium and fonts, to read Office files, web pages and emails + +FROM cloudron/base:5.1.0@sha256:1c0666c9abe9e2090d33686826d4e97769b799124573118d41e0d7485135748e AS frontend +ENV PATH="/usr/local/node-24.19.0/bin:$PATH" COREPACK_ENABLE_DOWNLOAD_PROMPT=0 +WORKDIR /app +RUN corepack enable +COPY nextjs-frontend/package.json nextjs-frontend/pnpm-lock.yaml nextjs-frontend/pnpm-workspace.yaml ./ +RUN pnpm install --frozen-lockfile +COPY nextjs-frontend/ ./ +ENV NEXT_TELEMETRY_DISABLED=1 +RUN AUTH_SECRET=build-only pnpm build && pnpm prune --prod && rm -rf .next/cache + +FROM cloudron/base:5.1.0@sha256:1c0666c9abe9e2090d33686826d4e97769b799124573118d41e0d7485135748e + +ARG EXTRAS="" +ARG FULL=false + +# tesseract: text on screen; antiword + poppler: legacy .doc and PDF fallbacks (ffmpeg is in the base image) +RUN apt-get update \ + && apt-get install -y --no-install-recommends tesseract-ocr antiword poppler-utils \ + && if [ "$FULL" = "true" ]; then apt-get install -y --no-install-recommends \ + libreoffice-writer-nogui libreoffice-calc-nogui libreoffice-impress-nogui \ + chromium fonts-dejavu-core fonts-liberation2 fonts-noto-core fonts-noto-cjk; fi \ + && case " $EXTRAS " in *" doctr "*) apt-get install -y --no-install-recommends libgl1 libglib2.0-0;; esac \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=surrealdb/surrealdb:v3.2.4 /surreal /usr/local/bin/surreal +COPY --from=rclone/rclone:1.75.1 /usr/local/bin/rclone /usr/local/bin/rclone +COPY --from=ghcr.io/astral-sh/uv:0.8 /uv /usr/local/bin/uv + +ENV PATH="/app/code/venv/bin:/usr/local/node-24.19.0/bin:$PATH" \ + PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + NEXT_TELEMETRY_DISABLED=1 + +# The backend, in a virtualenv built against the base image's Python 3.12 +WORKDIR /app/code/backend +COPY fastapi_backend/pyproject.toml fastapi_backend/uv.lock fastapi_backend/README.md ./ +RUN UV_PROJECT_ENVIRONMENT=/app/code/venv UV_PYTHON_DOWNLOADS=never UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy \ + uv sync --frozen --no-dev --no-install-project --python /usr/bin/python3.12 \ + $(for e in $EXTRAS; do printf -- '--extra %s ' "$e"; done) +COPY fastapi_backend/ ./ +RUN UV_PROJECT_ENVIRONMENT=/app/code/venv UV_PYTHON_DOWNLOADS=never UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy \ + uv sync --frozen --no-dev --python /usr/bin/python3.12 \ + $(for e in $EXTRAS; do printf -- '--extra %s ' "$e"; done) \ + && rm -rf /root/.cache + +# The web app, built in the stage above; Next writes its cache to /run (the code is read-only on Cloudron) +WORKDIR /app/code/frontend +COPY --from=frontend /app/package.json /app/next.config.mjs ./ +COPY --from=frontend /app/node_modules ./node_modules +COPY --from=frontend /app/.next ./.next +COPY --from=frontend /app/public ./public +RUN ln -s /run/lens/next-cache .next/cache + +COPY cloudron/start.sh cloudron/supervisord.conf cloudron/archive.yaml cloudron/export-db.sh /app/code/cloudron/ +RUN chmod +x /app/code/cloudron/*.sh + +WORKDIR /app/code +CMD [ "/app/code/cloudron/start.sh" ] diff --git a/cloudron/CHANGELOG b/cloudron/CHANGELOG new file mode 100644 index 000000000..fc3a75ff1 --- /dev/null +++ b/cloudron/CHANGELOG @@ -0,0 +1,2 @@ +[0.3.0] +* First Cloudron package: SurrealDB 3.2.4, the API, a job worker and the web app in one app diff --git a/cloudron/DESCRIPTION.md b/cloudron/DESCRIPTION.md new file mode 100644 index 000000000..62ecf6b24 --- /dev/null +++ b/cloudron/DESCRIPTION.md @@ -0,0 +1,17 @@ +Lens is an archive for recorded speech and video. It transcribes recordings, tells speakers apart, makes everything +searchable (full text and by meaning), builds a knowledge graph of the people, places and topics mentioned, and +publishes recordings as IIIF. Its assistant answers questions with citations to the exact moment in a recording. + +### Features + +* **Transcription and speakers:** transcripts with word timings, speaker diarisation and voice IDs. +* **Search:** full-text and semantic search across transcripts, documents and images. +* **Knowledge graph:** entities and their relations, per namespace or shared. +* **Assistant:** chat with your archive through any OpenAI-compatible model server (Ollama, llama.cpp, vLLM, LM Studio). +* **Publishing:** an embeddable transcript player, static reports, and IIIF Presentation 3 with Content Search. + +### This package + +SurrealDB, the API, a background worker and the web app run together in one app. The database and the archive's +files live in the app's data directory and are included in Cloudron backups, with a fresh database export every +six hours. diff --git a/cloudron/POSTINSTALL.md b/cloudron/POSTINSTALL.md new file mode 100644 index 000000000..8f36b4b84 --- /dev/null +++ b/cloudron/POSTINSTALL.md @@ -0,0 +1,5 @@ +Lens has no accounts yet. Create the first admin at $CLOUDRON-APP-ORIGIN/setup with the **setup code** printed in +the app's logs (search for "setup code"), or read it in the web terminal with `grep LENS_SETUP_CODE /app/data/secrets.env`. + +Recordings to watch go in `/app/data/media` (File manager, or `cloudron push`). Processing settings are in +`/app/data/archive.yaml` and in the app under Settings. diff --git a/cloudron/README.md b/cloudron/README.md new file mode 100644 index 000000000..949d7a4d2 --- /dev/null +++ b/cloudron/README.md @@ -0,0 +1,79 @@ +# Lens on Cloudron + +The repository root is a Cloudron package: `CloudronManifest.json`, `Dockerfile.cloudron` and this folder. One app +runs SurrealDB, the API, a job worker and the web app under supervisord; only the web app is public, and it serves +the API's paths itself. Needs Cloudron 9.1 or later. + +| Where | What | +|---|---| +| `/app/data/secrets.env` | secrets made on first start (session keys, database password, setup code); keep it | +| `/app/data/archive.yaml` | processing configuration, written once from `cloudron/archive.yaml`, then yours to edit | +| `/app/data/surreal` | the SurrealDB database (SurrealKV) | +| `/app/data/backup/lens.surql` | a database export, refreshed every six hours, so backups always hold a consistent copy | +| `/app/data/archive` | `data_dir`: uploads, frames, reports, model caches | +| `/app/data/media` | a folder the app may watch: put recordings here (File manager or `cloudron push`) | + +Mail for password resets goes through Cloudron's mail server (the sendmail addon). + +## Install on your Cloudron + +With the [Cloudron CLI](https://www.npmjs.com/package/cloudron) on your computer, from a checkout of this +repository: + +```bash +npm install -g cloudron +cloudron login my.example.com # your Cloudron's dashboard address +cloudron install --location lens -f Dockerfile.cloudron +``` + +The CLI uploads the source and your Cloudron builds the image itself, so no registry is needed. Then open the app: +the post-install note says where the first-admin **setup code** is (the app's logs, or +`grep LENS_SETUP_CODE /app/data/secrets.env` in the web terminal). + +Update to a newer checkout with `cloudron update --app lens -f Dockerfile.cloudron`; logs with +`cloudron logs --app lens -f`. + +Build options go with `--build-arg`: `FULL=true` adds LibreOffice, Chromium and fonts (Office files, web pages, +emails), `EXTRAS="sensevoice voices"` adds backend extras as in `fastapi_backend/Dockerfile`. Raise the memory limit +in the app's Resources page for large models. + +## Build once, install from an image + +To build on another machine instead, push the image to a registry your Cloudron can pull from (a public one, or one +added under Settings → Docker registries): + +```bash +docker build -f Dockerfile.cloudron -t ghcr.io/you/lens-cloudron:0.3.0 . +docker push ghcr.io/you/lens-cloudron:0.3.0 +cloudron install --location lens --image ghcr.io/you/lens-cloudron:0.3.0 +``` + +## Publish as a community app + +Cloudron 9.1 and later install community apps from a `CloudronVersions.json` file at a public URL, with updates +offered as new versions are added to it. + +```bash +cloudron versions init # once: creates CloudronVersions.json +cloudron versions add --image ghcr.io/you/lens-cloudron:0.3.0 +git add CloudronVersions.json && git commit -m "Cloudron: publish 0.3.0" && git push +``` + +Then install it from the dashboard (App Store, community app, with the file's raw URL) or with +`cloudron install --location lens --versions-url https://raw.githubusercontent.com/adeelahmad/lense/main/CloudronVersions.json`. +For each release: bump `version` in `CloudronManifest.json`, add a `[x.y.z]` entry to `cloudron/CHANGELOG`, push a +new image tag and run `cloudron versions add` again. The image must be public. + +## Restore the database from its export + +If the live database files in a backup don't open, load the export into a fresh database (web terminal): + +```bash +supervisorctl -c /app/code/cloudron/supervisord.conf stop api worker surrealdb +mv /app/data/surreal /app/data/surreal.broken && mkdir /app/data/surreal && chown cloudron:cloudron /app/data/surreal +supervisorctl -c /app/code/cloudron/supervisord.conf start surrealdb +source /app/data/secrets.env +surreal import --endpoint http://127.0.0.1:8001 --user root --pass "$SURREAL_PASS" \ + --namespace archive --database main /app/data/backup/lens.surql +supervisorctl -c /app/code/cloudron/supervisord.conf start api worker +``` diff --git a/cloudron/archive.yaml b/cloudron/archive.yaml new file mode 100644 index 000000000..27082542d --- /dev/null +++ b/cloudron/archive.yaml @@ -0,0 +1,13 @@ +# Lens processing configuration on Cloudron. Written to /app/data/archive.yaml on first start and yours to edit +# afterwards (restart the app to apply). Every key is documented in fastapi_backend/archive.example.yaml; most +# settings can also be changed in the web app. +data_dir: /app/data/archive # reports, frames, uploads, model caches, locks +namespaces: # one folder tree per namespace; add more as you need them + media: # (a fresh database also needs at least one to start) + paths: [/app/data/media] + graph: shared +workers: + inline: 0 # the worker process does the work +sources: + # folders the web app may watch: put recordings in /app/data/media (Cloudron's file manager, or `cloudron push`) + local_roots: [/app/data/media] diff --git a/cloudron/export-db.sh b/cloudron/export-db.sh new file mode 100644 index 000000000..2e1bbe47d --- /dev/null +++ b/cloudron/export-db.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Writes a consistent SurrealQL export of the database to /app/data/backup every few hours, so Cloudron's backups +# (which copy /app/data while the app runs) always hold a clean copy next to the live database files. +set -u +umask 077 # the export holds the whole archive + +INTERVAL="${LENS_EXPORT_INTERVAL_SECONDS:-21600}" +OUT=/app/data/backup/lens.surql + +sleep 600 # let the app settle after a start +while true; do + if surreal export --endpoint http://127.0.0.1:8001 --user root --pass "${SURREAL_PASS}" \ + --namespace "${SURREAL_NS:-archive}" --database "${SURREAL_DB:-main}" "${OUT}.tmp"; then + mv "${OUT}.tmp" "${OUT}" + echo "export-db: wrote ${OUT}" + else + rm -f "${OUT}.tmp" + echo "export-db: export failed, keeping the previous one" + fi + sleep "${INTERVAL}" +done diff --git a/cloudron/logo.png b/cloudron/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..7ea79d8ebdb469e60bcb35459471eca6ffddfe64 GIT binary patch literal 13787 zcmXY2cRZD08-9=NnAtOX%ibz`lbIr$tgOgL#>ptFY|6+XMD}RNo{=ppgi0usBqZaz z&-Z=5{!lsZdfxlF?rYp9-sF-F1)2qoAP9w?uBI7+py014goFrw*!Y*Z!Ve-R107A| z6!!<)`YatmI1xQfHH(nEt^7MSBm4i}+W%~Rs!7?+wkmO-ZCZj)Sm}Rmn1FSZ!zn*U$CokVv>7bR$)0cKBGdU`y#TsUc2Ki#n|DGX!O>XW3d8$ z?s8<|%+52tGL86tZ^W-q{|vy zTY`d2OvFgo2vf5_BUh&@lJ~m~8Bu3GLZjb&#^a0+xOmlFV+D7my8&m>%d7~)QJ=rRb<@cX8T5i3GktC;E)O4rKh8FS0Hg9aNZ<+Az_6q=gs3O5MYTiOQWK? zM9h#~w>x2swdL0M}_TRmOC`t7BWULM=5h5eE zwU9NWQSgBzoJdWVXt|&1-?bU}?{99uI*VJw6xMSnP5%+2!0@NjsO7I8BZ6%y1O)}- z)UP0FZ`$-K_>i?0dJKVJ@IQLGm4_nEUIj13#U$bW9-xl!_$rLm)Hp&&uoTXl59P$C zT}dSfaVH&PTtwBH&y#mKxgp|%A+~rX@g2D9|9UjQbj@ZWQ6G&o7iRpLP_A!i__aRH zb3WpTDf#RLb!}}TDJiM#qrU-uBdL$eznP}y=8_>2a&kn-RV%Bzl0;-=WENG{^p`6v zwf=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5H9)ZZj!D_hl4}Bv$@|?mw##6W@Jd8*EP$#*AgRt?s7E&o zsp)1iz+Xm|sb9Q|Qdbl>gTbF#CMF<3I@*7bik?xoS1V+zXU|!AawDT?#Q-D!DUXV% z_H2i;`n;Kmgz5=uxs&Oi9m&m3d}RCiZ$CkVQF2pAkcngsIeLaoE}$lgk0#m zs)A?~mYWq}u_iK+_>a)T8TPfERB43^z#Wj4CC?0nAzL{V$8`OnlkTv=X&M#WdtH2Hj z9N?)^_4kMq65j1cQ4=~yI&Vg0JnZ+u-WaWxB)pLK;Jk zuZqh1t&gBDQHE-G7#3k8%TT1IF uWM4?8{O1g+7 First start: creating secrets" + { + echo "ACCESS_SECRET_KEY=$(openssl rand -hex 32)" + echo "ARCHIVE_SECRET_KEY=$(openssl rand -hex 32)" + echo "AUTH_SECRET=$(openssl rand -hex 32)" + echo "SURREAL_PASS=$(openssl rand -hex 16)" + echo "LENS_SETUP_CODE=$(openssl rand -hex 6)" + } > /app/data/secrets.env + chmod 600 /app/data/secrets.env +fi +set -a +# shellcheck disable=SC1091 +source /app/data/secrets.env +set +a + +# Processing configuration: written once, then the admin's to edit (Cloudron's file manager or web terminal) +[ -f /app/data/archive.yaml ] || cp /app/code/cloudron/archive.yaml /app/data/archive.yaml + +export HOME=/app/data/home XDG_CACHE_HOME=/app/data/home/.cache +export SURREAL_URL=ws://127.0.0.1:8001 SURREAL_USER=root +export ARCHIVE_CONFIG=/app/data/archive.yaml +export RUN_BACKGROUND=false +export FRONTEND_URL="${CLOUDRON_APP_ORIGIN}" +export CORS_ORIGINS="[\"${CLOUDRON_APP_ORIGIN}\"]" + +# Mail for password resets and access requests (Cloudron's sendmail addon: plain SMTP inside the server) +if [ -n "${CLOUDRON_MAIL_SMTP_SERVER:-}" ]; then + export MAIL_SERVER="${CLOUDRON_MAIL_SMTP_SERVER}" MAIL_PORT="${CLOUDRON_MAIL_SMTP_PORT}" \ + MAIL_USERNAME="${CLOUDRON_MAIL_SMTP_USERNAME}" MAIL_PASSWORD="${CLOUDRON_MAIL_SMTP_PASSWORD}" \ + MAIL_FROM="${CLOUDRON_MAIL_FROM}" MAIL_FROM_NAME="${CLOUDRON_MAIL_FROM_DISPLAY_NAME:-Lens}" \ + MAIL_STARTTLS=False MAIL_SSL_TLS=False USE_CREDENTIALS=True VALIDATE_CERTS=False +fi + +# The web app: the Next.js server reaches the API on localhost +export API_BASE_URL=http://127.0.0.1:8000 AUTH_URL="${CLOUDRON_APP_ORIGIN}" AUTH_TRUST_HOST=true NODE_ENV=production + +chown -R cloudron:cloudron /app/data /run/lens + +echo "==> First-admin setup code (only needed until the first account exists): ${LENS_SETUP_CODE}" +exec /usr/bin/supervisord --configuration /app/code/cloudron/supervisord.conf --nodaemon diff --git a/cloudron/supervisord.conf b/cloudron/supervisord.conf new file mode 100644 index 000000000..4c19b77cb --- /dev/null +++ b/cloudron/supervisord.conf @@ -0,0 +1,74 @@ +; Lens on Cloudron: every process logs to stdout, which is the app's log in the dashboard (and `cloudron logs`). +[supervisord] +nodaemon=true +user=root +logfile=/run/lens/supervisord.log +pidfile=/run/lens/supervisord.pid +childlogdir=/run/lens + +[unix_http_server] +file=/run/lens/supervisor.sock +chmod=0700 + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///run/lens/supervisor.sock + +[program:surrealdb] +priority=10 +user=cloudron +command=/usr/local/bin/surreal start --log info --bind 127.0.0.1:8001 --user root --pass %(ENV_SURREAL_PASS)s surrealkv:/app/data/surreal/lens.db +autorestart=true +stopwaitsecs=60 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +redirect_stderr=true + +[program:api] +priority=20 +user=cloudron +directory=/app/code/backend +command=/bin/bash -c 'until surreal is-ready --endpoint http://127.0.0.1:8001 >/dev/null 2>&1; do sleep 1; done; exec fastapi run app/main.py --host 127.0.0.1 --port 8000 --proxy-headers' +autorestart=true +stopasgroup=true +killasgroup=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +redirect_stderr=true + +[program:worker] +priority=30 +user=cloudron +directory=/app/code/backend +command=/bin/bash -c 'until surreal is-ready --endpoint http://127.0.0.1:8001 >/dev/null 2>&1; do sleep 1; done; exec lens worker' +autorestart=true +stopasgroup=true +killasgroup=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +redirect_stderr=true + +[program:web] +priority=40 +user=cloudron +directory=/app/code/frontend +command=/app/code/frontend/node_modules/.bin/next start --hostname 0.0.0.0 --port 3000 +autorestart=true +stopasgroup=true +killasgroup=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +redirect_stderr=true + +[program:export-db] +priority=50 +user=cloudron +command=/app/code/cloudron/export-db.sh +autorestart=true +stopasgroup=true +killasgroup=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +redirect_stderr=true diff --git a/docs/deployment.md b/docs/deployment.md index 6a69c90a4..dd94146a1 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -46,6 +46,13 @@ docker compose -f docker-compose.prod.yml logs backend | grep "setup code" (such as Chrome's). * **IIIF.** Set `iiif.base_url` to the stable public address before publishing anything; identifiers are built from it. +## Cloudron + +The repository is also a Cloudron package: SurrealDB, the API, a worker and the web app in one app, installed from a +checkout with `cloudron install --location lens -f Dockerfile.cloudron`. See +[cloudron/README.md](https://github.com/adeelahmad/lense/blob/main/cloudron/README.md) for data locations, updates +and publishing it as a community app. + ## Frontend on Vercel The Next.js app can be deployed to Vercel (`prod-frontend-deploy.yml`) with `API_BASE_URL` pointing at the API's From 747b4c62454b9ad4a067b3ff00a57e9eb3ce5ea6 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Oct 2026 12:35:08 +0000 Subject: [PATCH 2/4] Cloudron image: build and push on every published release Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01NdWJn5kdhHYz3mjiuQ2mVU --- .github/workflows/cloudron.yml | 29 +++++++++++++++++++++-------- CHANGELOG.md | 2 +- cloudron/README.md | 7 +++++-- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cloudron.yml b/.github/workflows/cloudron.yml index 28921242d..b3cffea22 100644 --- a/.github/workflows/cloudron.yml +++ b/.github/workflows/cloudron.yml @@ -1,8 +1,11 @@ name: Cloudron image -# Builds the Cloudron package (Dockerfile.cloudron) when it changes; run it by hand to push the image to GHCR for +# Builds the Cloudron package (Dockerfile.cloudron) when it changes. A published release pushes the image to GHCR, +# tagged with the release version and `latest`; run it by hand to push the manifest's version. The image is for # `cloudron install --image` or `cloudron versions add` (cloudron/README.md). on: + release: + types: [published] pull_request: paths: [Dockerfile.cloudron, CloudronManifest.json, cloudron/**, .dockerignore] workflow_dispatch: @@ -21,15 +24,25 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Image name and tag (the manifest's version) + - name: Image name and tags (the release's version, else the manifest's) id: meta + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + PUSH: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.push) }} run: | - echo "image=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/lens-cloudron" >> "$GITHUB_OUTPUT" - echo "version=$(jq -r .version CloudronManifest.json)" >> "$GITHUB_OUTPUT" + image="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/lens-cloudron" + version="${RELEASE_TAG#v}" + [ -n "$version" ] || version=$(jq -r .version CloudronManifest.json) + tags="$image:$version" + [ -z "$RELEASE_TAG" ] || tags="$tags,$image:latest" + echo "image=$image" >> "$GITHUB_OUTPUT" + echo "version=$version" >> "$GITHUB_OUTPUT" + echo "tags=$tags" >> "$GITHUB_OUTPUT" + echo "push=$PUSH" >> "$GITHUB_OUTPUT" - uses: docker/setup-buildx-action@v3 - - if: github.event_name == 'workflow_dispatch' && inputs.push + - if: steps.meta.outputs.push == 'true' uses: docker/login-action@v3 with: registry: ghcr.io @@ -40,13 +53,13 @@ jobs: with: context: . file: Dockerfile.cloudron - push: ${{ github.event_name == 'workflow_dispatch' && inputs.push }} - tags: ${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.version }} + push: ${{ steps.meta.outputs.push == 'true' }} + tags: ${{ steps.meta.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max - name: Summary - if: github.event_name == 'workflow_dispatch' && inputs.push + if: steps.meta.outputs.push == 'true' run: | echo "Pushed \`${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.version }}\`." >> "$GITHUB_STEP_SUMMARY" echo "Make the package public on GitHub so Cloudron can pull it." >> "$GITHUB_STEP_SUMMARY" diff --git a/CHANGELOG.md b/CHANGELOG.md index efc7e09d9..bf5758220 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version - The database is exported to `/app/data/backup/lens.surql` every six hours, so Cloudron's backups always hold a consistent copy alongside the live files. - It can also be published as a community app (`cloudron versions add`), with the image built and pushed to - GHCR by the new "Cloudron image" workflow. + GHCR by the new "Cloudron image" workflow on every published release. - **Fix: Chat answers no longer break off with "The answer stopped before it finished".** With some model servers an answer ended mid-stream with nothing saved, so the question sat unanswered in the conversation. Now each one ends diff --git a/cloudron/README.md b/cloudron/README.md index 949d7a4d2..477e790a8 100644 --- a/cloudron/README.md +++ b/cloudron/README.md @@ -53,16 +53,19 @@ cloudron install --location lens --image ghcr.io/you/lens-cloudron:0.3.0 Cloudron 9.1 and later install community apps from a `CloudronVersions.json` file at a public URL, with updates offered as new versions are added to it. +Publishing a GitHub release builds the image and pushes it to `ghcr.io/adeelahmad/lens-cloudron:` +(and `:latest`) with the "Cloudron image" workflow; make that package public once on GitHub. Then: + ```bash cloudron versions init # once: creates CloudronVersions.json -cloudron versions add --image ghcr.io/you/lens-cloudron:0.3.0 +cloudron versions add --image ghcr.io/adeelahmad/lens-cloudron:0.3.0 git add CloudronVersions.json && git commit -m "Cloudron: publish 0.3.0" && git push ``` Then install it from the dashboard (App Store, community app, with the file's raw URL) or with `cloudron install --location lens --versions-url https://raw.githubusercontent.com/adeelahmad/lense/main/CloudronVersions.json`. For each release: bump `version` in `CloudronManifest.json`, add a `[x.y.z]` entry to `cloudron/CHANGELOG`, push a -new image tag and run `cloudron versions add` again. The image must be public. +release (which pushes the image) and run `cloudron versions add` again. The image must be public. ## Restore the database from its export From 7b95b0f4707a930f3e10c03d022d584b8cb73a13 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Oct 2026 12:41:36 +0000 Subject: [PATCH 3/4] Cloudron image: build a release tag passed by the Release workflow Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01NdWJn5kdhHYz3mjiuQ2mVU --- .github/workflows/cloudron.yml | 13 ++++++++++--- cloudron/README.md | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cloudron.yml b/.github/workflows/cloudron.yml index b3cffea22..113febac2 100644 --- a/.github/workflows/cloudron.yml +++ b/.github/workflows/cloudron.yml @@ -1,7 +1,8 @@ name: Cloudron image # Builds the Cloudron package (Dockerfile.cloudron) when it changes. A published release pushes the image to GHCR, -# tagged with the release version and `latest`; run it by hand to push the manifest's version. The image is for +# tagged with the release version and `latest`; the Release workflow starts it with `tag` (a release published with +# GITHUB_TOKEN fires no release event). Run by hand without `tag`, it pushes the manifest's version. The image is for # `cloudron install --image` or `cloudron versions add` (cloudron/README.md). on: release: @@ -10,6 +11,10 @@ on: paths: [Dockerfile.cloudron, CloudronManifest.json, cloudron/**, .dockerignore] workflow_dispatch: inputs: + tag: + description: "Release tag to build and push as that version and latest (vX.Y.Z); empty: the manifest's version" + type: string + default: "" push: description: "Push to ghcr.io//lens-cloudron" type: boolean @@ -23,12 +28,14 @@ jobs: packages: write steps: - uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || github.ref }} - name: Image name and tags (the release's version, else the manifest's) id: meta env: - RELEASE_TAG: ${{ github.event.release.tag_name }} - PUSH: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.push) }} + RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tag }} + PUSH: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && (inputs.push || inputs.tag != '')) }} run: | image="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/lens-cloudron" version="${RELEASE_TAG#v}" diff --git a/cloudron/README.md b/cloudron/README.md index 477e790a8..95defac17 100644 --- a/cloudron/README.md +++ b/cloudron/README.md @@ -64,8 +64,8 @@ git add CloudronVersions.json && git commit -m "Cloudron: publish 0.3.0" && git Then install it from the dashboard (App Store, community app, with the file's raw URL) or with `cloudron install --location lens --versions-url https://raw.githubusercontent.com/adeelahmad/lense/main/CloudronVersions.json`. -For each release: bump `version` in `CloudronManifest.json`, add a `[x.y.z]` entry to `cloudron/CHANGELOG`, push a -release (which pushes the image) and run `cloudron versions add` again. The image must be public. +For each release: add a `[x.y.z]` entry to `cloudron/CHANGELOG`, run the Release workflow (it sets the version in +`CloudronManifest.json` and starts the image build), then `cloudron versions add` again. The image must be public. ## Restore the database from its export From ca53b6ff8ba5d674d66f733ed7b138a983b87fbd Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Oct 2026 12:50:53 +0000 Subject: [PATCH 4/4] Cloudron: FULL build without Chromium (Ubuntu 24.04 has only a snap stub) Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01NdWJn5kdhHYz3mjiuQ2mVU --- Dockerfile.cloudron | 5 +++-- cloudron/README.md | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile.cloudron b/Dockerfile.cloudron index a4df2eb8c..0006fe135 100644 --- a/Dockerfile.cloudron +++ b/Dockerfile.cloudron @@ -2,7 +2,8 @@ # supervisord. Only the web app (port 3000) is public; it proxies the API's paths (lib/api/backend-proxy.ts). # Build and install: see cloudron/README.md. # --build-arg EXTRAS="sensevoice voices" optional backend extras, as in fastapi_backend/Dockerfile -# --build-arg FULL=true LibreOffice, Chromium and fonts, to read Office files, web pages and emails +# --build-arg FULL=true LibreOffice and fonts, to read Office files, text, saved web pages and emails +# (no Chromium: Ubuntu 24.04's apt package is a snap stub, so no web capture) FROM cloudron/base:5.1.0@sha256:1c0666c9abe9e2090d33686826d4e97769b799124573118d41e0d7485135748e AS frontend ENV PATH="/usr/local/node-24.19.0/bin:$PATH" COREPACK_ENABLE_DOWNLOAD_PROMPT=0 @@ -24,7 +25,7 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends tesseract-ocr antiword poppler-utils \ && if [ "$FULL" = "true" ]; then apt-get install -y --no-install-recommends \ libreoffice-writer-nogui libreoffice-calc-nogui libreoffice-impress-nogui \ - chromium fonts-dejavu-core fonts-liberation2 fonts-noto-core fonts-noto-cjk; fi \ + fonts-dejavu-core fonts-liberation2 fonts-noto-core fonts-noto-cjk; fi \ && case " $EXTRAS " in *" doctr "*) apt-get install -y --no-install-recommends libgl1 libglib2.0-0;; esac \ && rm -rf /var/lib/apt/lists/* diff --git a/cloudron/README.md b/cloudron/README.md index 95defac17..acc4cbf40 100644 --- a/cloudron/README.md +++ b/cloudron/README.md @@ -33,8 +33,8 @@ the post-install note says where the first-admin **setup code** is (the app's lo Update to a newer checkout with `cloudron update --app lens -f Dockerfile.cloudron`; logs with `cloudron logs --app lens -f`. -Build options go with `--build-arg`: `FULL=true` adds LibreOffice, Chromium and fonts (Office files, web pages, -emails), `EXTRAS="sensevoice voices"` adds backend extras as in `fastapi_backend/Dockerfile`. Raise the memory limit +Build options go with `--build-arg`: `FULL=true` adds LibreOffice and fonts (Office files, text, saved web pages, +emails; capturing live web pages needs Chromium, which this package leaves out), `EXTRAS="sensevoice voices"` adds backend extras as in `fastapi_backend/Dockerfile`. Raise the memory limit in the app's Resources page for large models. ## Build once, install from an image