Note: For a detailed annotation of Dockerfile and source code, refer to the files in the preceding folders: MVP_App and MVP_Docker
announce_prefix3.js
angular.module('myApp', ['app-ip'])
.controller('HomeCtrl', function ($scope, $http) {
$scope.info = {};
$scope.buttonpressed = false;
$scope.c = 0;
$scope.PrefixRemoved = 0;
$scope.PrefixFound = 0;
$scope.AddaPrefix = 0;
$scope.PrefixAdded = 0;
$scope.DeleteAPrefix = 0;
$scope.PrefixRemain = 1000;
$scope.validaddress = false;
$scope.showAdd = true;
$scope.repush = false;
$scope.repushed = false;
$scope.PhaseOne = true;
$scope.DBSearched = false;
$scope.AddSuccess = 0;
$scope.PushedErr = false;
$scope.PrefixCopied = 0;
$scope.ReadOnly = true;
$scope.info.nexthop = "null"
$scope.info.aspath = "null"
$scope.info.localpref = "null"
$scope.info.prefix = "null"
$scope.info.neighbor = "null"
$scope.info.opnotes = "null"
$scope.Repush = function () {
$scope.PhaseOne = false
$scope.repush = true
$http({
method: 'POST',
url: 'http://HOST-REF:30000/repush',
}).then(function (response) {
results = response.data
$scope.PrefixCopied = results['result']
$scope.repushed = results['pushed']
$scope.PreFix = results['prefix']
$scope.NHop = results['nhop']
$scope.PushedErr = results['pusherr']
$scope.message = results['msg']
}, function (error) {
$scope.PushedErr = results['pusherr']
$scope.status = results['stat']
$scope.message = results['msg']
});
}
$scope.selectentry = function () {
$scope.info.prefix = $scope.ipAddress1
$scope.buttonpressed = true
$http({
method: 'POST',
url: '/SearchPrefix',
data: {
info: $scope.info
}
}).then(function (response) {
results = response.data
var myWindow = window.open("", "popup", "width=200,height=100");
myWindow.document.write("<p>" + results['result'] + " " + results['message'] + "</p>");
$scope.PrefixFound = results['result']
}, function (error) {
var myWindow = window.open("", "popup", "width=200,height=100");
myWindow.document.write("<p>" + results['message'] + "</p>");
});
}
$scope.Addentry = function () {
$scope.AddaPrefix = 1
}
$scope.Removeentry = function () {
$scope.DeleteAPrefix = 1
}
$scope.DBaseSearch = function () {
$scope.PhaseOne = false
$scope.repush = false
$scope.DBSearched = true
}
$scope.DenounceEntry = function () {
$scope.testout = $scope.info.prefix
$http({
method: 'POST',
url: 'http://HOST-REF:30000/RemovePrefix',
data: {
info: $scope.info
}
}).then(function (response) {
results = response.data
$scope.PrefixRemain = results['result']
}, function (error) {
console.log(error);
});
}
$scope.AnnouncePrefix = function () {
$http({
method: 'POST',
url: 'http://HOST-REF:30000/AnnouncePrefix',
data: {
info: $scope.info
}
}).then(function (response) {
results = response.data
$scope.AddSuccess = results['result']
var myWindow = window.open("", "popup", "width=200,height=100");
myWindow.document.write("<p>" + results['result'] + " " + results['message'] + "</p>");
}, function (error) {
console.log(error);
});
}
$scope.SearchPrefix = function () {
$http({
method: 'POST',
url: 'http://HOST-REF:30000/SearchPrefix',
data: {
info: $scope.info
}
}).then(function (response) {
results = response.data
var myWindow = window.open("", "popup", "width=200,height=100");
myWindow.document.write("<p>" + results['result'] + " " + results['message'] + "</p>");
}, function (error) {
console.log(error);
});
}
})
app-ip.js
var app = angular.module('app-ip', ['ng-ip-address']);
app.controller('HomeCtrl', ['$scope', function($scope) {
$scope.allowPort = {allowPort: true};
$scope.requirePort = {requirePort: true};
$scope.portConfig = {requirePort: false, allowPort: true};
}]);
000-default.conf
<VirtualHost *:8081>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 8081
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
bower.json
{
"name": "html",
"description": "",
"main": "",
"license": "MIT",
"homepage": "",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
}
}
Docker file
############################################################
# Dockerfile to build angular script and js reference container images.
# these script “pages” must be referenced and reachable as urls by the model container
# Based on Ubuntu
############################################################
# Set the base image to Ubuntu
FROM ubuntu:latest
# File Author / Maintainer
MAINTAINER Mike Pate
# Update the repository sources list
RUN apt-get update --fix-missing
################## BEGIN INSTALLATION ######################
# Install View; apps
# Ref: https://www.digitalocean.com/community/tutorials/how-to-manage-front-end-javascript-and-css-dependencies-with-bower-on-ubuntu-14-04
#install curl
RUN apt-get install curl -y
################## Prerequisites ####################
################## apache server #####
#install apache server
RUN apt-get install apache2 -y
RUN apt-get update -y
#
#change aoache2 listening port
COPY ports.conf /etc/apache2/ports.conf
COPY 000-default.conf /etc/apache2/sites-enabled/000-default.conf
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
#install GIT
RUN apt-get install git -y
# Install Node.js on your server
RUN apt-get install nodejs -y
#Install npm on your server
RUN apt-get install npm -y
# your binary may be called nodejs instead of node
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN apt-get update
################## Directory Structures ##############
#create directory structure
################## where HTML Resides ##############
RUN mkdir Container_BGP_Portal
################## where Bower resides #############
RUN mkdir Container_BGP_Portal/Bower
################## where angularjs script ##########
RUN mkdir Container_BGP_Portal/js
#
################## Bower Install #################
#into target directory
#RUN npm install --prefix /Container_BGP_Portal/Bower bower -g --allow-root
RUN npm install bower -g --allow-root
# RUN npm update -g bower
RUN apt-get update -y
# RUN apt-get upgrade -y
# There is no built-in option for bower but the unix yes command will work. It outputs its argument followed by a newline indefinitely.
# Using yes with empty string will be like hitting enter to accept the defaults.
RUN echo '{ "allow_root": true }' > /root/.bowerrc
################### Angularjs ######################
#RUN find / -name "bower_components" -print
COPY wrapper.sh wrapper.sh
RUN chmod +x wrapper.sh
WORKDIR "/var/www/html"
################### Bootstrap and BOWER Components #####################
Copy bower.json ./bower.json
RUN bower install angularjs --save
RUN bower install bootstrap --save
RUN bower install jquery --save
RUN bower install ng-ip-address --save
RUN bower install bootstrap-css --save
COPY app-ip.js app-ip.js
################## Copy application js scripts over ##########
COPY announce_prefix3.js announce_prefix3.js
RUN chmod +x announce_prefix3.js
RUN chmod +x app-ip.js
RUN bower update
RUN apt-get update -y
RUN apt-get upgrade -y
#expose apache2's listening port
EXPOSE 8081
WORKDIR "/"
# Set default container command
# ENTRYPOINT /bin/bash
CMD ./wrapper.sh
wrapper.sh
#!bin/bash
echo "export Svc_Host=e.2a.3da9.ip4.static.sl-reverse.com" >> ~/.bash_login
echo "export Svc_IP=169.61.42.14" >> ~/.bash_login
source ~/.bash_login
echo "$Svc_Host $Svc_IP" >> /etc/hosts
sed -i "s/HOST-REF/$Svc_Host/g" /var/www/html/announce_prefix3.js
service apache2 restart
exec /bin/bash -c "trap : TER