[Fuego] [PATCH] Move fuego-ro/core to image during build and keep core as submodule

Guilherme Campos Camargo guicc at profusion.mobi
Fri Feb 16 21:45:57 UTC 2018


Hello, everyone

Those directories ideally shoud be copied to the image during build time
given that Fuego would not run if their content is not available. By
doing this, we're also making sure that a user that plans to use
fuego-base docker image directly (or as a base image for his own docker
images) will be able to do it straightforwardly, without the need of
cloning other repositories or bind-mounting host's directories.

It's also a good idea to keep fuego-core locked in a fixed release, what
we can enforce easily by using git submodules. This is desired if we
want to use a stable version of fuego to test new versions of fuego.

On this patch we configure fuego-core as a submodule and make the
changes needed for copying the required contents of the mentioned
directories.

--
Tim, please let us know what you think about it.

Thanks

Signed-off-by: Guilherme Campos Camargo <guicc at profusion.mobi>
---
 .dockerignore                                 |  2 --
 .gitmodules                                   |  3 +++
 Dockerfile                                    |  7 +++++++
 fuego-core                                    |  1 +
 fuego-host-scripts/docker-build-image.sh      | 14 ++++++++++++++
 fuego-host-scripts/docker-create-container.sh |  7 -------
 6 files changed, 25 insertions(+), 9 deletions(-)
 create mode 100644 .gitmodules
 create mode 160000 fuego-core

diff --git a/.dockerignore b/.dockerignore
index d73e89c..6af69cd 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,4 +1,2 @@
-fuego-rw
-fuego-ro
 fuego-host-scripts
 .git
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..d1adb2a
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "fuego-core"]
+	path = fuego-core
+	url = https://bitbucket.org/tbird20d/fuego-core.git
diff --git a/Dockerfile b/Dockerfile
index cc79351..fc394ad 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -106,6 +106,13 @@ RUN curl -L -O ${JENKINS_URL} && \
     dpkg -i jenkins_${JENKINS_VERSION}_all.deb && \
     rm jenkins_${JENKINS_VERSION}_all.deb
 
+# ==============================================================================
+# Install fuego-core and fuego-ro
+# ==============================================================================
+COPY fuego-ro /fuego-ro
+COPY fuego-rw /fuego-rw
+COPY fuego-core /fuego-core
+
 # ==============================================================================
 # Post installation
 # ==============================================================================
diff --git a/fuego-core b/fuego-core
new file mode 160000
index 0000000..5bf5f81
--- /dev/null
+++ b/fuego-core
@@ -0,0 +1 @@
+Subproject commit 5bf5f81baba3ae107d4316a628825e38f1f98094
diff --git a/fuego-host-scripts/docker-build-image.sh b/fuego-host-scripts/docker-build-image.sh
index d276ee0..b345f0a 100755
--- a/fuego-host-scripts/docker-build-image.sh
+++ b/fuego-host-scripts/docker-build-image.sh
@@ -1,5 +1,19 @@
 #!/bin/bash
 # $1 - name for the docker image (default: fuego)
+
+SOURCE="${BASH_SOURCE[0]}"
+while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
+  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+  SOURCE="$(readlink "$SOURCE")"
+  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
+done
+DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+
+echo "${DIR}"/../fuego-core/.git
+if [ ! -e "${DIR}"/../fuego-core/.git ]; then
+    git submodule update --init
+fi
+
 DOCKERIMAGE=${1:-fuego}
 
 sudo docker build -t ${DOCKERIMAGE} \
diff --git a/fuego-host-scripts/docker-create-container.sh b/fuego-host-scripts/docker-create-container.sh
index 3d133bd..53a7a7a 100755
--- a/fuego-host-scripts/docker-create-container.sh
+++ b/fuego-host-scripts/docker-create-container.sh
@@ -12,11 +12,6 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
 DOCKERIMAGE=${1:-fuego}
 DOCKERCONTAINER=${2:-fuego-container}
 
-if [ ! -d $DIR/../../fuego-core ]; then
-   echo "You need to clone fuego-core at $DIR/../../fuego-core"
-   exit 1
-fi
-
 if [ "${UID}" == "0" ]; then
 	uid=$(id -u "${SUDO_USER}")
 	gid=$(id -g "${SUDO_USER}")
@@ -31,8 +26,6 @@ sed -i "s/docker_jenkins_gid=500/docker_jenkins_gid=$gid/" $DIR/../fuego-ro/conf
 sudo docker create -it --name ${DOCKERCONTAINER} \
     -v /boot:/boot:ro \
     -v $DIR/../fuego-rw:/fuego-rw \
-    -v $DIR/../fuego-ro:/fuego-ro:ro \
-    -v $DIR/../../fuego-core:/fuego-core:ro \
     -e http_proxy=${http_proxy} \
     -e https_proxy=${https_proxy:-$http_proxy} \
     --net="host" ${DOCKERIMAGE} || \
-- 
2.16.1



More information about the Fuego mailing list