FROM python:3.12-slim

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    HOME=/home/hobees \
    UV_TOOL_DIR=/opt/uv-tools \
    UV_TOOL_BIN_DIR=/usr/local/bin

# 1. Install uv system-wide as root
RUN pip install --no-cache-dir uv

# 2. Create non-root user and directories
RUN groupadd --system --gid 1000 hobees \
    && useradd --system --uid 1000 --gid hobees --home-dir ${HOME} --create-home hobees \
    && mkdir -p ${HOME}/output ${HOME}/skills ${HOME}/config /opt/uv-tools \
    && chown -R hobees:hobees ${HOME} /opt/uv-tools

# 3. Install hobees into /opt/uv-tools with symlink in /usr/local/bin
RUN uv tool install hobees && chmod -R a+rX /opt/uv-tools ${HOME}

# 4. Copy default config and entrypoint
COPY --chown=hobees:hobees hobees.yaml ${HOME}/config/hobees.yaml
COPY --chown=hobees:hobees docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

USER hobees
WORKDIR ${HOME}

ENTRYPOINT ["/entrypoint.sh"]
