FROM python:3.13-slim

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# frotz provides dfrotz (z-machine interpreter for interactive fiction)
RUN apt-get update \
    && apt-get install -y --no-install-recommends frotz \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# install deps first (better layer caching)
COPY pyproject.toml ./
# replace local-path telnetlib3 dep with PyPI version for container build
RUN sed -i 's|telnetlib3 @ file:///home/jtm/src/telnetlib3|telnetlib3>=2.3.0|' pyproject.toml \
    && uv sync --no-dev --no-install-project

# copy project source and content
COPY src/ src/
COPY content/ content/
COPY worlds/ worlds/
RUN uv sync --no-dev

EXPOSE 6789

ENV MUD_HOST=0.0.0.0

CMD ["uv", "run", "python", "-m", "mudlib"]
