aido-onyx/smb-connector/Dockerfile
Naeem Dosh afac2c42ae SMB connector: mount CIFS shares inside the container (like Lobehub)
Client asked to mount the SMB share in Docker rather than on the host. Added an
opt-in in-container CIFS mount:
- entrypoint.sh mounts each source's share (mount -t cifs) from env
  (SMB_SOURCE_<N>_UNC or _SERVER+_SHARE, _USERNAME/_PASSWORD/_DOMAIN/_VERS),
  read-only, credentials via a 0600 file (never in the process list), then drops
  from root to the unprivileged app user via gosu and execs the sync app;
  unmounts cleanly on stop.
- Dockerfile installs cifs-utils + gosu, runs the mount entrypoint.
- docker-compose.smb.yml adds cap_add [SYS_ADMIN, DAC_READ_SEARCH] +
  apparmor:unconfined (privileged fallback noted).
- .env.example + README document in-container mode; legacy host-bind-mount mode
  still works (omit _UNC/_SERVER for that source).

Entrypoint logic validated (POSIX sh check + mocked dry-run: correct mount args,
guest fallback, creds file, privilege drop). Live CIFS round-trip to be run
against a real SMB server; the sync engine is already E2E-verified.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 23:14:46 +05:00

26 lines
934 B
Docker

# AIDO SMB → Onyx sync connector
FROM python:3.12-slim
ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
# cifs-utils: mount SMB/CIFS shares inside the container (no host mount needed).
# gosu: drop from root (needed for mount) to the unprivileged app user at runtime.
RUN apt-get update \
&& apt-get install -y --no-install-recommends cifs-utils gosu \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY app/ ./app/
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# App runs as this unprivileged user (entrypoint mounts as root, then drops to it).
# State dir is a mounted volume so the manifest survives restarts.
RUN useradd -u 10001 -m runner && mkdir -p /app/state && chown -R runner /app/state
VOLUME ["/app/state"]
# Root entrypoint mounts CIFS shares, then execs the app via gosu as `runner`.
ENTRYPOINT ["/entrypoint.sh"]