FROM debian:bookworm-slim

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
      curl ca-certificates bash git build-essential python3 libatomic1 && \
    rm -rf /var/lib/apt/lists/*

# Install mise
ENV MISE_YES=1
RUN curl https://mise.run | sh
ENV PATH="/root/.local/bin:$PATH"

# Pre-install node and bun
RUN mise use -g node@latest bun@latest

# Copy the packed tarball and install via both package managers
COPY tobilu-qmd-*.tgz /tmp/
RUN mise exec node@latest -- npm install -g /tmp/tobilu-qmd-*.tgz
RUN mise exec bun@latest -- bun install -g /tmp/tobilu-qmd-*.tgz

# Copy test project (src + test + configs) and install deps
COPY test-src/ /opt/qmd/
RUN cd /opt/qmd && mise exec node@latest -- npm install 2>/dev/null
RUN cd /opt/qmd && mise exec bun@latest -- bun install 2>/dev/null || true

# Put everything on PATH
ENV PATH="/root/.bun/bin:/root/.local/share/mise/shims:/root/.local/bin:$PATH"

CMD ["bash"]
