[Fuego] [PATCH] docker-container: allow user to override JENKINS_PORT

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Thu Feb 21 00:46:40 UTC 2019


Install.sh already supports specifying the port for Jenkins.
That is useful when you want to install Fuego on a machine
that is already using 8080.

Another use case is to install multiple instances of Fuego
on the same machine. Creating one image per jenkins port
is quite inefficient. Instead, we want to create a container
for each port and override the Jenkins port.

This patch allows overriding the environment variable
JENKINS_PORT, used by ftc or common.sh for example. However,
it requires an extra step (modify jenkins configuration
file) which needs to be done manually (see the script).

It would be nice to automatize that step with the parameter
--entrypoint but I haven't been succesful yet.

Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
---
 fuego-host-scripts/docker-create-container.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fuego-host-scripts/docker-create-container.sh b/fuego-host-scripts/docker-create-container.sh
index b223861..97917c8 100755
--- a/fuego-host-scripts/docker-create-container.sh
+++ b/fuego-host-scripts/docker-create-container.sh
@@ -1,12 +1,22 @@
 #!/bin/bash
 # $1 - name for the docker image (default: fuego)
 # $2 - name for the docker container (default: fuego-container)
+# $3 - overrides JENKINS_PORT env variable
+#      Additionally you need to change the port on the config manually
+#      docker# sed -i -e 's#8080#8082#g' /etc/default/jenkins
+#      docker# service jenkins restart
 
 DIR=$(dirname $(realpath "${BASH_SOURCE[0]}"))
 
 DOCKERIMAGE=${1:-fuego}
 DOCKERCONTAINER=${2:-fuego-container}
 
+if [ -z "${3}" ]; then
+    JENKINS_PORT_ENV=""
+else
+    JENKINS_PORT_ENV="--env JENKINS_PORT=${3}"
+fi
+
 if [ ! -d $DIR/../fuego-core ]; then
    echo "You need to clone fuego-core at $DIR/../fuego-core"
    exit 1
@@ -19,5 +29,6 @@ sudo docker create -it --name ${DOCKERCONTAINER} \
     -v $DIR/../fuego-ro:/fuego-ro:ro \
     -v $DIR/../fuego-core:/fuego-core:ro \
     --env no_proxy="$no_proxy" \
+    $JENKINS_PORT_ENV \
     --net="host" ${DOCKERIMAGE} || \
     echo "Could not create fuego-container. See error messages."
-- 
2.7.4



More information about the Fuego mailing list