#--------------------------------------------------------------------------#
#  Copyright (c) 2020-2024, Ciena Corporation                              #
#  All rights reserved.                                                    #
#                                                                          #
#     _______ _____ __    __ ___                                           #
#    / _ __(_) ___//  |  / // _ |                                          #
#   / /   / / /__ / /|| / // / ||                                          #
#  / /___/ / /__ / / ||/ // /__||                                          #
# /_____/_/_____/_/  |__//_/   ||                                          #
#                                                                          #
#  PROPRIETARY NOTICE                                                      #
#  This Software consists of confidential information.                     #
#  Trade secret law and copyright law protect this Software.               #
#  The above notice of copyright on this Software does not indicate        #
#  any actual or intended publication of such Software.                    #
#                                                                          #
#--------------------------------------------------------------------------#
FROM ubuntu:20.04

#
# Build commands
#

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

# Prepare the base image
SHELL ["/bin/bash", "-c"]
RUN apt update -y
RUN apt upgrade -y

# Install debug utilities
RUN apt install apt-utils -y
RUN apt install net-tools -y
RUN apt install iputils-ping -y
RUN apt install iproute2 -y
RUN apt install libssl-dev -y
RUN apt install openssl -y

# Install the Tibit Netconf binary package
RUN mkdir -p /tmp
WORKDIR /tmp
COPY tibit-netconf-confd_R5.2.0_amd64.deb /tmp
RUN cd /tmp && apt install ./tibit-netconf-confd_R5.2.0_amd64.deb -y

# Copy NACM init configuration
COPY docker/aaa_init.xml /var/tibit/confd/cdb/aaa_init.xml

# Create a Linux 'tibit' user for accessing the Tibit Netconf server
RUN useradd -ms /bin/bash tibit
RUN echo "tibit:tibit" | chpasswd


# Install supervisord
RUN apt install -y supervisor
COPY docker/supervisord.conf /etc/supervisor/supervisord.conf

#
# Runtime commands
#

# Use supervisord to run Netopeer2 + Tibit Database Connector
CMD /usr/bin/supervisord -c /etc/supervisor/supervisord.conf

#CMD bash
