FROM ubuntu:24.04 AS builder
WORKDIR /src
RUN apt-get update -y && apt-get install -y \
    cmake gettext build-essential ninja-build git
COPY neovim .
RUN make CMAKE_BUILD_TYPE=RelWithDebInfo
RUN make install DESTDIR=/build-output

FROM ubuntu:24.04 AS runner
COPY --from=builder /build-output /
COPY --from=golang:1.24 /usr/local/go /usr/local/go
ENV PATH="/usr/local/go/bin:${PATH}"
RUN apt-get update -y && apt-get install -y \
    git curl gpg software-properties-common fzf fd-find ripgrep \
    && add-apt-repository ppa:deadsnakes/ppa \
    && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
    && apt-get install -y python3.13 python3.13-venv python3-pip nodejs \
    && rm -rf /var/lib/apt/lists/* \
    && npm install -g tree-sitter-cli \
    && python3.13 -m pip install --break-system-packages pynvim
RUN npm install -g neovim
RUN useradd -m -s /bin/bash t0xa
WORKDIR /home/t0xa/.config/nvim
COPY . .

RUN chown -R t0xa /home/t0xa
USER t0xa
