aido-onyx/smb-connector/docker-compose.smb.yml
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

46 lines
1.7 KiB
YAML

# Add this service to your Onyx docker-compose (same `onyx-network`).
#
# docker compose -f docker-compose.yml -f smb-connector/docker-compose.smb.yml up -d smb_connector
#
# The connector mounts the SMB/CIFS shares INSIDE the container (default mode) —
# no host mount needed. Just give it the share + credentials via env (see
# smb-connector/.env.example). For that, the container needs the two capabilities
# and the unconfined apparmor profile below (required for mount.cifs in a
# container; the host also needs the `cifs` kernel module, which is standard).
services:
smb_connector:
build: ./smb-connector
image: livtec/aido-smb-connector:local
container_name: aido-smb-connector
restart: unless-stopped
networks:
- onyx-network
env_file:
- path: ./smb-connector/.env
required: false
depends_on:
api_server:
condition: service_healthy
# --- required to mount SMB/CIFS shares inside the container ---------------
cap_add:
- SYS_ADMIN
- DAC_READ_SEARCH
security_opt:
- apparmor:unconfined
# If your host's Docker still refuses the mount, use privileged mode instead
# of the two cap_add lines above:
# privileged: true
volumes:
# Persist the sync manifest + cached api-key/cc_pair (survives restarts).
- ./smb-connector/state:/app/state
# NOTE: no host bind-mounts of the shares are needed in in-container mode.
# (Legacy host-mount mode still works: bind-mount the share here and OMIT
# the SMB_SOURCE_*_SERVER/_UNC env for that source, e.g.
# - /mnt/smb/finance:/mnt/smb/finance:ro )
logging:
driver: json-file
options:
max-size: "50m"
max-file: "6"