# Base development image with common tools
FROM ubuntu:24.04

# Prevent interactive prompts during apt install
ENV DEBIAN_FRONTEND=noninteractive

# Install base tools plus sudo so the entrypoint permission fixer can
# chown runtime mounts staged by the API before dropping to the user.
RUN apt-get update && apt-get install -y \
    curl \
    wget \
    git \
    neovim \
    ranger \
    tmux \
    htop \
    tree \
    jq \
    ca-certificates \
    sudo \
    && rm -rf /var/lib/apt/lists/*

# Use the shared built-in UID/GID so writable Config Profile mounts can be
# shared by compatible instances without ownership changes.
RUN groupadd -g 1000 user \
    && useradd -m -u 1000 -g 1000 -s /bin/bash user \
    && echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/user \
    && chmod 0440 /etc/sudoers.d/user
WORKDIR /home/user

# Install Node.js (needed for pi and many dev tools)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y nodejs \
    && rm -rf /var/lib/apt/lists/*

# Set up git configuration defaults
RUN git config --global init.defaultBranch main \
    && git config --global user.email "dev@headquarter.local" \
    && git config --global user.name "Developer"

USER user
CMD ["/bin/bash"]