FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y \
    python3 python3-pip \
    golang-go rustc cargo \
    r-base \
    sqlite3 build-essential git curl wget \
    bash zsh \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Installer jj
RUN curl -LO https://github.com/martinvonz/jj/releases/latest/download/jj-x86_64-unknown-linux-gnu \
    && chmod +x jj-x86_64-unknown-linux-gnu \
    && mv jj-x86_64-unknown-linux-gnu /opt/bin/jj

# Installer jj_lsp (si binaire séparé)
RUN curl -LO https://github.com/martinvonz/jj/releases/latest/download/jj_lsp-x86_64-unknown-linux-gnu \
    && chmod +x jj_lsp-x86_64-unknown-linux-gnu \
    && mv jj_lsp-x86_64-unknown-linux-gnu /opt/bin/jj_lsp

COPY opt/bin/ /opt/bin/
COPY opt/dev-tools/ /opt/dev-tools/
COPY opt/lm-client/ /opt/lm-client/

ENV PATH="/opt/bin:/opt/dev-tools:/opt/lm-client:${PATH}"

ARG USERNAME=devuser
ARG USER_UID=1000
ARG USER_GID=1000
RUN groupadd --gid $USER_GID $USERNAME \
    && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

COPY docker-entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

USER $USERNAME
WORKDIR /workspace

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["/bin/bash"]
