Running silverbullet with plugin in offline environment, how to preload plugins?

I'm running silverbullet with plugin in offline environment. Is there a simple way to preload plugins?

Right now my solution is something like

Dockerfile

# Use the official SilverBullet image as base
FROM zefhemel/silverbullet:v2

# Install curl/jq for plug downloads and git for history plug
# Alpine-based images use apk package manager
RUN apk add --no-cache curl jq git \
  && git config --system --add safe.directory /space

# Copy the entrypoint script that will download the plug on startup
COPY entrypoint.sh /usr/local/bin/entrypoint.sh

# Make the entrypoint script executable
RUN chmod +x /usr/local/bin/entrypoint.sh

# Set the custom entrypoint that will download the plug before starting SilverBullet
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

# Default command to start SilverBullet (from the base image)
CMD ["/silverbullet"]

entrypoint.sh

#!/bin/sh
set -e

# Configuration
PLUG_DIR="/space/_plug"

echo "==> SilverBullet Entrypoint: Starting..."

# Detect the user/group that owns the /space directory
SPACE_UID=$(stat -c '%u' /space 2>/dev/null || stat -f '%u' /space 2>/dev/null || echo "1000")
SPACE_GID=$(stat -c '%g' /space 2>/dev/null || stat -f '%g' /space 2>/dev/null || echo "1000")

# Recreate _plug directory fresh
echo "==> Recreating _plug directory at: ${PLUG_DIR}"
rm -rf "$PLUG_DIR"
mkdir -p "$PLUG_DIR"
chown "$SPACE_UID":"$SPACE_GID" "$PLUG_DIR"

# Define plug URLs to download
PLUG_URLS="
https://github.com/MrMugame/silversearch/releases/latest/download/silversearch.plug.js
https://github.com/LogeshG5/silverbullet-drawio/releases/latest/download/drawio.plug.js
https://raw.githubusercontent.com/silverbulletmd/silverbullet-mermaid/main/mermaid.plug.js
https://github.com/deepkn/silverbullet-graphview/releases/latest/download/graphview.plug.js
https://raw.githubusercontent.com/joekrill/silverbullet-treeview/main/treeview.plug.js
https://raw.githubusercontent.com/Tagirijus/HeadingsPicker/main/headingspicker.plug.js
https://raw.githubusercontent.com/ivanalejandro0/silverbullet-history/refs/heads/main/dist/history.plug.js

"
# History plug is not working

# Download each plug
echo "$PLUG_URLS" | while read -r url; do
  # Skip empty lines
  [ "$url" = "" ] && continue

  # Extract filename from URL
  filename=$(basename "$url")

  echo "==> Downloading ${filename}..."
  echo "    URL: ${url}"

  if curl -L -f -o "${PLUG_DIR}/${filename}" "$url"; then
    echo "    ✓ Success"
    chmod 644 "${PLUG_DIR}/${filename}"
    chown "$SPACE_UID":"$SPACE_GID" "${PLUG_DIR}/${filename}"
  else
    echo "    ✗ Failed to download ${filename}"
  fi
done


echo "==> Plug installation complete"
echo "==> Installed plugs:"
ls -lh "$PLUG_DIR"

echo "==> Starting SilverBullet..."
# Execute the original command (start SilverBullet)
exec "$@"

But it has been brittle. Is there any more built-in/simple way to preload the container with plugins?

Question: what's the goal here? Why not simply rely on those plugs being served from your space folder?

I think I came under the impression that silverbullet updates can clear the plug folder. I don't remember what led me to believe that, don't know if it is true.

No, that shouldn’t happen