# Dockerfile to make a container from built Wheel package in source code (uv build)
# To build the image: docker build -t <imagename> .
# Then to run it interactively: docker run -it --rm <imagename>

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
COPY ./dist/hobees*.whl ${HOME}/
RUN LATEST_WHL=$(ls -v ${HOME}/hobees*.whl | tail -n 1) \
    && uv tool install "${LATEST_WHL}" \
    && chmod -R a+rX /opt/uv-tools ${HOME}

USER hobees
WORKDIR ${HOME}

CMD [ "hobees" ]
