FROM quay.io/fedora/fedora:43

# === install system packages ===
RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
  dnf update -y && \
  dnf -y --setopt=keepcache=1 install procps ping bash-completion glibc-langpack-en \
    host-spawn dbus-launch \
    git pnpm helix zip rsync

# === setup user ===
RUN useradd -ms /bin/bash user && \
  usermod -aG wheel user && sed -i '/NOPASSWD/s/^#//g' /etc/sudoers && \
  mkdir -p /run/user/1000 && chown user:user /run/user/1000

# === Add host entry for podman ===
RUN ln -s /usr/local/bin/host /usr/local/bin/podman

USER user
WORKDIR /home/user
RUN mkdir .config .local .cache

COPY --chown=user:user config/bashrc .bashrc
COPY --chown=user:user config/git .config/git/config
COPY --chown=user:user config/helix/ .config/helix/
COPY config/bin /usr/local/bin

# === Setup PNPM & install language servers ===
RUN /bin/bash -c "SHELL=/bin/bash pnpm setup && . /home/user/.bashrc && pnpm i -g deno bash-language-server vscode-langservers-extracted dockerfile-language-server-nodejs \
    typescript typescript-language-server"

VOLUME /home/user
