FROM ubuntu:jammy
RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive \
    TZ=Europe/Berlin \
    apt-get install -y \
	apt-utils \
	autoconf \
	bc \
	bison \
	build-essential \
	cmake \
	doxygen \
	g++ \
	flex \
	git \
	kmod \
	libboost-coroutine-dev \
	libboost-fiber-dev \
	libboost-iostreams-dev \
	libelf-dev \
	libglib2.0-dev \
	libgoogle-perftools-dev \
	libpcap-dev \
	libpixman-1-dev \
	libprotobuf-dev \
	ninja-build \
	protobuf-compiler \
	python-is-python3 \
	python3-dev \
	python3-sphinx \
	python3-sphinx-rtd-theme \
	rsync \
	scons \
	unzip \
	wget \
	nano \
	vim \
 && rm -rf /var/lib/apt/lists/*
COPY verilator.patch /tmp/
RUN cd /tmp \
 && git clone -b v4.010 https://github.com/verilator/verilator \
 && cd verilator \
 && patch -p1 < /tmp/verilator.patch \
 && autoupdate \
 && autoconf \
 && ./configure \
 && make -j`nproc` \
 && make install \
 && rm -rf /tmp/verilator

# Add non-root user for vs code devcontainer.
ARG USERNAME=simbricks
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
 && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME --shell /bin/bash \
# Add sudo support for this user and remove the need to type in password.
 && apt-get update \
 && apt-get install -y sudo \
 && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
 && chmod 0440 /etc/sudoers.d/$USERNAME
