FROM debian:11

RUN apt update
RUN apt install -y \
         git debhelper g++ make cmake libspandsp-dev flite1-dev \
         libspeex-dev libgsm1-dev libopus-dev libssl-dev python3-dev \
         python3.9-dev libev-dev \
         python3-sip-dev openssl libev-dev libmysqlcppconn-dev libevent-dev \
         libxml2-dev libcurl4-openssl-dev libhiredis-dev \
         cargo rustc

RUN apt install -y \
         devscripts libbcg729-dev \
         libsamplerate-dev libmp3lame-dev libcodec2-dev
COPY . /sems
WORKDIR /sems

RUN mkdir -p build && cd build && cmake .. && make sems_tests && ./core/sems_tests
RUN ls -al pkg/deb/bullseye/*
RUN ln -s pkg/deb/bullseye ./debian
RUN ls -al debian/*
RUN dch -b -v $(cat VERSION) "sems"
RUN dpkg-buildpackage -rfakeroot -us -uc
RUN ls -al ..

RUN dpkg -i ../sems_*.deb
RUN /usr/sbin/sems -v

# Run SEMS with the specified configuration
CMD ["/usr/sbin/sems", "-E", "-f", "/etc/sems/sems.conf"]
