FROM ubuntu:22.04

# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y \
    apt-transport-https autoconf automake bc binutils-dev build-essential \
    ca-certificates cmake curl devscripts dh-exec dh-python fakeroot gcc \
    git gnupg graphviz lftp libcap-ng-dev libdbus-1-dev libelf-dev \
    libibverbs-dev libjson-c-dev libnl-3-dev libnl-route-3-dev libnuma-dev \
    libpcap-dev librdmacm-dev libssl-dev libsystemd-dev libtool libudev-dev \
    libunbound-dev libunwind-dev lsb-release meson ninja-build \
    protobuf-compiler python3-all-dev python3-enchant python3-netifaces \
    python3-prometheus-client python3-pyelftools python3-sortedcontainers \
    python3-sphinx software-properties-common sparse sudo vim wget
# Create a non-root user for development
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=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
    && chmod 0440 /etc/sudoers.d/$USERNAME

# Set the default user
USER $USERNAME

# Set working directory
WORKDIR /workspaces

# Keep container running
CMD ["sleep", "infinity"]
