From: Eduardo Ramos Testillano (eramedu) Date: Wed, 13 May 2020 18:36:11 +0000 (+0200) Subject: Parametrize variants at build scripts X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=commitdiff_plain;h=60870aeb874273396e495c5c188ba12a614b5b1b Parametrize variants at build scripts Also, renamed adml-http image to anna-adml-http: Version is also -debug or for Release variant. New script for image check and cleanup. --- diff --git a/INSTALL_ADML_HTTP.md b/INSTALL_ADML_HTTP.md index 973862b..e4f9320 100644 --- a/INSTALL_ADML_HTTP.md +++ b/INSTALL_ADML_HTTP.md @@ -2,19 +2,19 @@ ## Deployment -Execute this [script](./example/diameter/launcher/deploy-adml-http.sh) and follow instructions. +Execute this [script](./example/diameter/launcher/deploy-adml-http.sh [Variant: Release by default]) and follow instructions. -## Enabling HTTP2 Service +## Building docker image -This is done through nginx proxy configured as reverse proxy to translate `HTTP2` traffic coming to port *8074* towards *localhost* port *8000* where `ADML HTTP` is going to serve the *HTTP1.1* Rest Service. +In our image, we enable the `HTTP2 Service` to attack the `HTTP1.1 ADML interface`. This is done through nginx proxy configured as reverse proxy to translate `HTTP2` traffic coming to port *8074* towards *localhost* port *8000* where `ADML HTTP` is going to serve the *HTTP1.1* Rest Service. To build the docker image, execute this script: -> tools/build-adml-http [variant: [Release]|Debug] +> tools/build-anna-adml-http [variant: [Release]|Debug] ## Running docker image -> docker run --rm -d -p 8074:8074 --name adml-http anna-adml-http: +> docker run --rm -d -p 8074:8074 --name anna-adml-http anna-adml-http: Service port is **8074**. @@ -22,11 +22,11 @@ Service port is **8074**. ### Monitoring ADML traces -> docker exec -it adml-http tail -F /opt/adml/launcher.trace +> docker exec -it anna-adml-http tail -F /opt/adml/launcher.trace ### Checking available diameter dictionaries -> docker exec -it adml-http ls -1 /opt/adml/stacks +> docker exec -it anna-adml-http ls -1 /opt/adml/stacks > > DictionaryGx.16777238.xml > DictionaryRx.16777236.xml diff --git a/example/diameter/launcher/deploy-adml-http.sh b/example/diameter/launcher/deploy-adml-http.sh index 0fc848e..97c5d72 100755 --- a/example/diameter/launcher/deploy-adml-http.sh +++ b/example/diameter/launcher/deploy-adml-http.sh @@ -6,6 +6,8 @@ SCR_DIR=`readlink -f $0 | xargs dirname` PROJECT_ROOT=$(readlink -f $SCR_DIR/../../..) +VARIANT=${1:-Release} + ############# # FUNCTIONS # ############# @@ -29,9 +31,9 @@ echo "------------------------------------------------------" echo " ADML with HTTP support installation " echo "------------------------------------------------------" echo -[ -d $PROJECT_ROOT/build/Release ] && VARIANT=Release -[ -d $PROJECT_ROOT/build/Debug ] && VARIANT=Debug -[ -z "$VARIANT" ] && _exit "Cannot locate neither 'Release' nor 'Debug' variant !" +[ ! -d $PROJECT_ROOT/build/${VARIANT} ] && _exit "Cannot locate neither '${VARIANT}' variant. Build the project !" +echo "Variant: ${VARIANT}" +echo build_type_letter=$(echo $VARIANT | cut -c1 | tr '[:upper:]' '[:lower:]') version__dflt=v"`date +'%y'`.`date +'%m'`.`date +'%d'`$build_type_letter" diff --git a/example/diameter/launcher/resources/HELP.md b/example/diameter/launcher/resources/HELP.md index 40f1a5e..abb842a 100644 --- a/example/diameter/launcher/resources/HELP.md +++ b/example/diameter/launcher/resources/HELP.md @@ -539,7 +539,7 @@ Implemented status codes: *200* (ok), *400* (bad request) and *405* (method not > curl -v --request GET localhost:8000 -You could also expose the service as HTTP2 server through *nginx* working as reverse proxy (*adml-http* image is built in this way although internally provides HTTP operations script only for 1.1). Then you could use HTTP2 clients like *nghttp*: +You could also expose the service as HTTP2 server through *nginx* working as reverse proxy (*anna-adml-http* image is built in this way although internally provides HTTP operations script only for 1.1). Then you could use HTTP2 clients like *nghttp*: > nghttp -v -H ":method: GET" "" @@ -579,7 +579,7 @@ Retrieve statistics xml report (will be *base64-encoded* at response). > curl -v --request POST -H "Content-Type: application/json" localhost:8000 -d@test.json -You could also expose the service as HTTP2 server through *nginx* working as reverse proxy (*adml-http* image is built in this way although internally provides HTTP operations script only for 1.1). Then you could use HTTP2 clients like *nghttp*: +You could also expose the service as HTTP2 server through *nginx* working as reverse proxy (*anna-adml-http* image is built in this way although internally provides HTTP operations script only for 1.1). Then you could use HTTP2 clients like *nghttp*: > nghttp -v -H ":method: POST" -d test.json "" @@ -840,7 +840,7 @@ Selects a context working node by mean a registered name (origin-host). If empty } ``` -**Response body**: +**Response body**: ``` { diff --git a/example/diameter/launcher/resources/rest_api/ct/ct.sh b/example/diameter/launcher/resources/rest_api/ct/ct.sh index 1ae0224..3fe561d 100755 --- a/example/diameter/launcher/resources/rest_api/ct/ct.sh +++ b/example/diameter/launcher/resources/rest_api/ct/ct.sh @@ -10,7 +10,7 @@ REPO_DIR="$(git rev-parse --show-toplevel 2>/dev/null)" SERVICES=${REPO_DIR}/example/diameter/launcher/resources/rest_api/ct/resources/servicesJson-request.json ENDPOINT=http://localhost:8074 PORT=$(echo ${ENDPOINT} | cut -d: -f3) -C_NAME=adml-http +C_NAME=anna-adml-http ############# # EXECUTION # @@ -26,7 +26,7 @@ echo echo "Rebuild ADML HTTP service image (y/n) [y]:" read opt [ -z "${opt}" ] && opt=y -[ "${opt}" = "y" ] && ${REPO_DIR}/tools/build-adml-http +[ "${opt}" = "y" ] && ${REPO_DIR}/tools/build-anna-adml-http version=$(${REPO_DIR}/tools/version) echo "Restart ADML HTTP service image (version '${version}') ..." diff --git a/tools/build-adml-http b/tools/build-adml-http deleted file mode 100755 index cdb9fce..0000000 --- a/tools/build-adml-http +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -############# -# VARIABLES # -############# - -REPO_DIR="$(git rev-parse --show-toplevel 2>/dev/null)" -[ -z "$REPO_DIR" ] && { echo "You must execute under a valid git repository !" ; exit 1 ; } - -IMAGEDIR=${REPO_DIR}/docker-images/anna-adml-http -AD=${IMAGEDIR}/opt/adml - -############# -# EXECUTION # -############# - -TAG=$(${REPO_DIR}/tools/version) - -# Docker build functions -source ${REPO_DIR}/tools/docker.src - -# Deploy Anna-ADML-HTTP: -rm -rf ${AD} -echo ${AD} | ${REPO_DIR}/example/diameter/launcher/deploy-adml-http.sh - -echo -echo "Generate docker image ..." -build_image ${IMAGEDIR} ${TAG} ${IMAGEDIR} || exit 1 - -echo -echo "Done !" -echo - diff --git a/tools/build-anna-adml-http b/tools/build-anna-adml-http new file mode 100755 index 0000000..d5b11c9 --- /dev/null +++ b/tools/build-anna-adml-http @@ -0,0 +1,41 @@ +#!/bin/bash + +############# +# VARIABLES # +############# + +REPO_DIR="$(git rev-parse --show-toplevel 2>/dev/null)" +[ -z "$REPO_DIR" ] && { echo "You must execute under a valid git repository !" ; exit 1 ; } + +IMAGEDIR=${REPO_DIR}/docker-images/anna-adml-http +AD=${IMAGEDIR}/opt/adml + +VARIANT=${1:-Release} + +############# +# EXECUTION # +############# + +echo +echo "Variant: ${VARIANT}" +echo "Remember usage: $0 [variant: <[Release]|Debug]>" +echo + +TAG=$(${REPO_DIR}/tools/version) + +# Docker build functions +source ${REPO_DIR}/tools/docker.src + +# Deploy Anna-ADML-HTTP: +rm -rf ${AD} +echo ${AD} | ${REPO_DIR}/example/diameter/launcher/deploy-adml-http.sh ${VARIANT} || exit 1 + +echo +echo "Generate docker image ..." +[ "${VARIANT}" = "Debug" ] && TAG=${TAG}-debug +build_image ${IMAGEDIR} ${TAG} ${IMAGEDIR} || exit 1 + +echo +echo "Done !" +echo + diff --git a/tools/build-with-docker b/tools/build-with-docker index 1fc7fdb..a7f6cfa 100755 --- a/tools/build-with-docker +++ b/tools/build-with-docker @@ -15,7 +15,8 @@ ENVS="-e VARIANT=${VARIANT}" ############# echo -echo "Remember usage: $0 [variant: Release|Debug], Release by default" +echo "Variant: ${VARIANT}" +echo "Remember usage: $0 [variant: <[Release]|Debug]>" echo TAG=$(${REPO_DIR}/tools/version) diff --git a/tools/check_docker_images.sh b/tools/check_docker_images.sh new file mode 100755 index 0000000..d0111ce --- /dev/null +++ b/tools/check_docker_images.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +get_anna_images() { + docker images| egrep 'anna-build-nodb|anna-adml-http' +} + +echo -e "\n=== IMAGES ===\n" +get_anna_images +echo -e "\n===============\n" + +# Removal: +echo "Proceed with cleanup ? (y/n) [n]" +read opt +[ -z "${opt}" ] && opt=n +[ "${opt}" = "n" ] && exit 0 +echo "Working ..." + +docker rmi -f $(get_anna_images | awk '{ print $3 }') &>/dev/null +docker system prune +echo +