FROM debian:bookworm-slim

# Install core Linux development utilities
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    curl \
    git \
    ssh-client \
    ca-certificates \
    sudo \
    gnupg \
    procps \
    unzip \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user 'vscode' with sudo privileges
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
    && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
    && echo $USERNAME ALL=\(ALL\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
    && chmod 0440 /etc/sudoers.d/$USERNAME

# Set the default user to the non-root user
USER $USERNAME
ENV HOME=/home/vscode