FROM quay.io/fedora/fedora:45

# === install system packages ===
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
  dnf update -y && \
  dnf -y --setopt=keepcache=1 --setopt=install_weak_deps=False install \
    bash-completion git-core fzf curl awk jq rg unzip which \
    host-spawn wl-copy gcc tree-sitter-cli diffutils procps-ng file patch

# === install tools (least to most frequently changing) ===
RUN echo "retry = 5" > /root/.curlrc # Also covers curl calls inside install scripts.

RUN set -o pipefail && \
  curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local bash && \
  ln -sf /usr/local/bin/bun /usr/local/bin/node

RUN set -o pipefail && \
  curl -fsSL https://github.com/neovim/neovim/releases/download/nightly/nvim-linux-x86_64.tar.gz | tar xz -C /usr/local --strip-components=1

RUN set -o pipefail && \
  curl -fsSL https://claude.ai/install.sh | bash && \
  cp -L /root/.local/bin/claude /usr/local/bin/ && \
  rm -rf /root/.local

COPY ./bin /usr/local/bin
COPY ./config/claude.md /etc/claude-code/CLAUDE.md

# === environment ===
ENV EDITOR=nvim \
  TZ=Europe/Amsterdam \
  XDG_RUNTIME_DIR=/run/user/1000 \
  WAYLAND_DISPLAY=wayland-0 \
  SSH_AUTH_SOCK=/run/user/1000/ssh-auth-sock \
  DISABLE_AUTOUPDATER=1

# === setup user ===
RUN useradd -ms /bin/bash user && \
  echo 'user ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/user && \
  mkdir -p /run/user/1000 && \
  chown user:user /run/user/1000

USER user
WORKDIR /home/user

RUN mkdir -p .config .local .cache && \
  git clone https://git.plabble.org/Job79/neovim-config.git .config/nvim

COPY --chown=user:user ./config/bashrc .bashrc
COPY --chown=user:user ./config/git .config/git/config

VOLUME /home/user
