FROM ubuntu:22.04

# Basic packages for iprouting and log
RUN apt-get update
RUN apt-get update && apt-get install -y  && apt-get install -y iproute2 iptables coreutils iputils-ping syslog-ng 

# Packages needed for the installation of libbpf and bpftool   
RUN apt-get install -y apt-transport-https ca-certificates curl clang llvm jq && \
apt-get install -y libelf-dev libpcap-dev libbfd-dev binutils-dev build-essential make && \
apt-get install -y linux-tools-common && \
apt-get install -y bpfcc-tools && \
apt-get install -y python3-pip git



# Libbpf installation
RUN git clone https://github.com/libbpf/libbpf && \
cd libbpf/src && \
make && \
make install && \
cd ../..

# Bpftool installation
RUN git clone --recurse-submodules https://github.com/libbpf/bpftool.git && \
    cd bpftool/src && \
    make install && \
    cd ../..

# Packages to run a very basic server
RUN apt-get install -y nodejs npm

# Starting of the very basic server
COPY ./server/package.json /app/package.json
COPY ./server/server.js	/app/server.js	
WORKDIR /app
RUN npm install
EXPOSE 3000 

WORKDIR /

# Package to communicate with flentd
RUN pip install numpy fluent-logger

# Package to test tcp comunication
RUN apt-get install socat   

ENV DEBIAN_FRONTEND=noninteractive

# Preconfigure tzdata with the desired timezone
RUN ln -fs /usr/share/zoneinfo/Europe/Madrid /etc/localtime && \
    echo "Europe/Madrid" > /etc/timezone && \
    apt-get update && \
    apt-get install -y tzdata && \
    dpkg-reconfigure --frontend noninteractive tzdata

# Copy of the entrypoint in the image
COPY entrypoints/ep_servidor.sh entrypoints/ep_servidor.sh
# Make the scripts executable 
RUN chmod +x /entrypoints/ep_servidor.sh


CMD ["/bin/bash"]




