# 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"]
