#--------------------------------------------------------------------------#
# Copyright (C) 2022 by Tibit Communications, Inc.                         #
# All rights reserved.                                                     #
#                                                                          #
#    _______ ____  _ ______                                                #
#   /_  __(_) __ )(_)_  __/                                                #
#    / / / / __  / / / /                                                   #
#   / / / / /_/ / / / /                                                    #
#  /_/ /_/_____/_/ /_/                                                     #
#                                                                          #
#  Distributed as Tibit-Customer confidential.                             #
#                                                                          #
#--------------------------------------------------------------------------#
FROM ubuntu:20.04

#
# Build commands
#
ARG VERSION

# Run the debian package manager in non-interactive mode
ARG DEBIAN_FRONTEND=noninteractive

# Prepare the base image
RUN apt-get update -y
RUN apt-get upgrade -y

# Install debug utilities
RUN apt-get install apt-utils -y
RUN apt-get install net-tools -y
RUN apt-get install iputils-ping -y
RUN apt-get install iproute2 -y
RUN apt-get install vim -y

# Install the PON Controller binary package
RUN mkdir -p /tmp
WORKDIR /tmp
COPY R${VERSION}-PonController-UB2004/tibit-poncntl_R${VERSION}_amd64.deb /tmp
RUN cd /tmp && apt-get install ./tibit-poncntl_R${VERSION}_amd64.deb -y
#VENKO Customization
RUN rm -f /opt/tibit/poncntl/database/SRV*.json



#
# Runtime commands
#

# PON Controller only, no UMT Relay and no Authenticator
# Run the binary PON Controller
#CMD /opt/tibit/poncntl/bin/tibit-poncntl -c /etc/tibit/poncntl/PonCntlInit.json

# PON Controller with UMT Relay and the Authenticator
#
# To enable all three services:
#   1) Comment out the 'PON Controller only' section above
#   2) Uncomment the following to start the PON Controller, UMT Relay,
#      and the Authenticator via supervisord.
RUN apt-get  install -y supervisor
COPY R${VERSION}-PonController-UB2004/docker/supervisord.conf /etc/supervisor/supervisord.conf
EXPOSE 9001
CMD /usr/bin/supervisord -c /etc/supervisor/supervisord.conf

#CMD bash
