From b946770c7476beb592c7efc274491a9abdd212a9 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Mon, 22 Jan 2018 11:08:59 -0600 Subject: [PATCH 1/5] test: Fix tests - run test for all distros Not all the distros were executed due to typo Signed-off-by: Jose Carlos Venegas Munoz --- tests/image_creation.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/image_creation.bats b/tests/image_creation.bats index b6e38104a8..0261fd9931 100644 --- a/tests/image_creation.bats +++ b/tests/image_creation.bats @@ -28,7 +28,7 @@ function build_image() distro="$1" [ -n "$distro" ] local rootfs="${tmp_dir}/rootfs-osbuilder" - sudo -E ${rootfs_sh} -r "${rootfs}" fedora + sudo -E ${rootfs_sh} -r "${rootfs}" "${distro}" sudo ${image_builder_sh} -s ${image_size} -o "${tmp_dir}/image.img" "${rootfs}" } From a617dd892ab43f028f6ca3ba2cc0a63511b4c17e Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Mon, 22 Jan 2018 13:18:15 -0600 Subject: [PATCH 2/5] dockerfiles: Add golang to centos anda euleros Signed-off-by: Jose Carlos Venegas Munoz --- rootfs-builder/centos/Dockerfile | 6 ++++++ rootfs-builder/euleros/Dockerfile | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/rootfs-builder/centos/Dockerfile b/rootfs-builder/centos/Dockerfile index fc96ef0a74..229f7a9c20 100644 --- a/rootfs-builder/centos/Dockerfile +++ b/rootfs-builder/centos/Dockerfile @@ -1 +1,7 @@ FROM centos:7 + +ADD https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz /tmp +RUN tar -C /usr/ -xzf /tmp/go1.9.2.linux-amd64.tar.gz +RUN yum install -y make +ENV GOROOT=/usr/go +ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin diff --git a/rootfs-builder/euleros/Dockerfile b/rootfs-builder/euleros/Dockerfile index e6250b2772..7c5a3c2c8c 100644 --- a/rootfs-builder/euleros/Dockerfile +++ b/rootfs-builder/euleros/Dockerfile @@ -1 +1,7 @@ FROM euleros:2.2 + +ADD https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz /tmp +RUN tar -C /usr/ -xzf /tmp/go1.9.2.linux-amd64.tar.gz +RUN yum install -y make +ENV GOROOT=/usr/go +ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin From 6dcaef7cf890f0207688893bf3a2fecac43e7721 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Mon, 22 Jan 2018 13:19:28 -0600 Subject: [PATCH 3/5] fedora: use OS_VERSION instead of host version Use OS_VERSION provided by user configuration and not use host version. Also add retries before fail on a request. Signed-off-by: Jose Carlos Venegas Munoz --- rootfs-builder/fedora/rootfs_lib.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rootfs-builder/fedora/rootfs_lib.sh b/rootfs-builder/fedora/rootfs_lib.sh index e2660f4de3..b3098d47ba 100755 --- a/rootfs-builder/fedora/rootfs_lib.sh +++ b/rootfs-builder/fedora/rootfs_lib.sh @@ -26,11 +26,12 @@ installonly_limit=3 #Dont use the default dnf reposdir #this will prevent to use host repositories reposdir=/root/mash +retries=5 [kata] -name=Fedora \$releasever - \$basearch +name=Fedora ${OS_VERSION} - \$basearch failovermethod=priority -metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-\$releasever&arch=\$basearch +metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-${OS_VERSION}&arch=\$basearch enabled=1 gpgcheck=0 EOF From 612754fd2044fa0af8a958f5aea9b3b1f202c2ae Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Tue, 23 Jan 2018 11:42:08 -0600 Subject: [PATCH 4/5] rootfs: Add support to create dockerfiles based on templates To simplify maintaince, create dockerfiles based on templates. This way when golang version is updated it will be done in one place versions.txt. This also allow to allways intall the same version of golang in any dockerfile. Signed-off-by: Jose Carlos Venegas Munoz --- rootfs-builder/.gitignore | 1 + rootfs-builder/centos/Dockerfile | 7 ------ rootfs-builder/centos/Dockerfile.in | 6 +++++ rootfs-builder/clearlinux/Dockerfile | 3 --- rootfs-builder/clearlinux/Dockerfile.in | 6 +++++ rootfs-builder/euleros/Dockerfile | 7 ------ rootfs-builder/euleros/Dockerfile.in | 5 ++++ rootfs-builder/euleros/config.sh | 2 +- rootfs-builder/euleros/rootfs_lib.sh | 4 +-- rootfs-builder/fedora/Dockerfile | 3 --- rootfs-builder/fedora/Dockerfile.in | 6 +++++ rootfs-builder/rootfs.sh | 27 +++++++++++++++++++++ rootfs-builder/template/Dockerfile.template | 11 +++++++++ rootfs-builder/template/Makefile | 5 ++++ rootfs-builder/versions.txt | 1 + tests/image_creation.bats | 4 +++ 16 files changed, 75 insertions(+), 23 deletions(-) create mode 100644 rootfs-builder/.gitignore delete mode 100644 rootfs-builder/centos/Dockerfile create mode 100644 rootfs-builder/centos/Dockerfile.in delete mode 100644 rootfs-builder/clearlinux/Dockerfile create mode 100644 rootfs-builder/clearlinux/Dockerfile.in delete mode 100644 rootfs-builder/euleros/Dockerfile create mode 100644 rootfs-builder/euleros/Dockerfile.in delete mode 100644 rootfs-builder/fedora/Dockerfile create mode 100644 rootfs-builder/fedora/Dockerfile.in create mode 100644 rootfs-builder/template/Dockerfile.template create mode 100644 rootfs-builder/versions.txt diff --git a/rootfs-builder/.gitignore b/rootfs-builder/.gitignore new file mode 100644 index 0000000000..94143827ed --- /dev/null +++ b/rootfs-builder/.gitignore @@ -0,0 +1 @@ +Dockerfile diff --git a/rootfs-builder/centos/Dockerfile b/rootfs-builder/centos/Dockerfile deleted file mode 100644 index 229f7a9c20..0000000000 --- a/rootfs-builder/centos/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM centos:7 - -ADD https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz /tmp -RUN tar -C /usr/ -xzf /tmp/go1.9.2.linux-amd64.tar.gz -RUN yum install -y make -ENV GOROOT=/usr/go -ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin diff --git a/rootfs-builder/centos/Dockerfile.in b/rootfs-builder/centos/Dockerfile.in new file mode 100644 index 0000000000..d16466d466 --- /dev/null +++ b/rootfs-builder/centos/Dockerfile.in @@ -0,0 +1,6 @@ +From centos:@OS_VERSION@ + +RUN yum -y update && yum install -y git make gcc + +# This will install the proper golang to build Kata components +@INSTALL_GO@ diff --git a/rootfs-builder/clearlinux/Dockerfile b/rootfs-builder/clearlinux/Dockerfile deleted file mode 100644 index fe52e95af7..0000000000 --- a/rootfs-builder/clearlinux/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -From fedora:27 - -RUN dnf -y update && dnf install -y git golang systemd pkgconfig diff --git a/rootfs-builder/clearlinux/Dockerfile.in b/rootfs-builder/clearlinux/Dockerfile.in new file mode 100644 index 0000000000..69c0b2badd --- /dev/null +++ b/rootfs-builder/clearlinux/Dockerfile.in @@ -0,0 +1,6 @@ +From fedora:27 + +RUN dnf -y update && dnf install -y git systemd pkgconfig gcc + +# This will install the proper golang to build Kata components +@INSTALL_GO@ diff --git a/rootfs-builder/euleros/Dockerfile b/rootfs-builder/euleros/Dockerfile deleted file mode 100644 index 7c5a3c2c8c..0000000000 --- a/rootfs-builder/euleros/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM euleros:2.2 - -ADD https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz /tmp -RUN tar -C /usr/ -xzf /tmp/go1.9.2.linux-amd64.tar.gz -RUN yum install -y make -ENV GOROOT=/usr/go -ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin diff --git a/rootfs-builder/euleros/Dockerfile.in b/rootfs-builder/euleros/Dockerfile.in new file mode 100644 index 0000000000..5378c65947 --- /dev/null +++ b/rootfs-builder/euleros/Dockerfile.in @@ -0,0 +1,5 @@ +FROM euleros:@OS_VERSION@ + +RUN yum -y update && yum install -y yum git make gcc +# This will install the proper golang to build Kata components +@INSTALL_GO@ diff --git a/rootfs-builder/euleros/config.sh b/rootfs-builder/euleros/config.sh index 86c0322b25..e3c627bfce 100644 --- a/rootfs-builder/euleros/config.sh +++ b/rootfs-builder/euleros/config.sh @@ -6,7 +6,7 @@ # Remove them or add more # EulerOS Version -OS_VERSION=${OS_VERSION:-2} +OS_VERSION=${OS_VERSION:-2.2} #Mandatory Packages that must be installed # systemd: An init system that will start kata-agent diff --git a/rootfs-builder/euleros/rootfs_lib.sh b/rootfs-builder/euleros/rootfs_lib.sh index 0b4ac19d72..62297a58f6 100644 --- a/rootfs-builder/euleros/rootfs_lib.sh +++ b/rootfs-builder/euleros/rootfs_lib.sh @@ -27,8 +27,8 @@ logfile=/var/log/yum-euleros.log exactarch=1 [Base] -name=EulerOS-2.2 Base -baseurl=http://developer.huawei.com/ict/site-euleros/euleros/repo/yum/2.2/os/x86_64/ +name=EulerOS-${OS_VERSION} Base +baseurl=http://developer.huawei.com/ict/site-euleros/euleros/repo/yum/${OS_VERSION}/os/x86_64/ enabled=1 gpgcheck=1 gpgkey=file://${CONFIG_DIR}/RPM-GPG-KEY-EulerOS diff --git a/rootfs-builder/fedora/Dockerfile b/rootfs-builder/fedora/Dockerfile deleted file mode 100644 index 9ccf104128..0000000000 --- a/rootfs-builder/fedora/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -From fedora:27 - -RUN dnf -y update && dnf install -y git golang redhat-release systemd pkgconfig diff --git a/rootfs-builder/fedora/Dockerfile.in b/rootfs-builder/fedora/Dockerfile.in new file mode 100644 index 0000000000..f98f36117d --- /dev/null +++ b/rootfs-builder/fedora/Dockerfile.in @@ -0,0 +1,6 @@ +From fedora:@OS_VERSION@ + +RUN dnf -y update && dnf install -y git redhat-release systemd pkgconfig gcc + +# This will install the proper golang to build Kata components +@INSTALL_GO@ diff --git a/rootfs-builder/rootfs.sh b/rootfs-builder/rootfs.sh index be5312865c..b8ab4473c8 100755 --- a/rootfs-builder/rootfs.sh +++ b/rootfs-builder/rootfs.sh @@ -12,6 +12,9 @@ ROOTFS_DIR=${ROOTFS_DIR:-${PWD}/rootfs} AGENT_VERSION=${AGENT_VERSION:-master} GO_AGENT_PKG=${GO_AGENT_PKG:-github.com/kata-containers/agent} AGENT_BIN=${AGENT_BIN:-kata-agent} +#Load default vesions for golang and other componets +source "${script_dir}/versions.txt" + # Name of file that will implement build_rootfs typeset -r LIB_SH="rootfs_lib.sh" @@ -79,6 +82,29 @@ check_function_exist() { [ "$(type -t ${function_name})" == "function" ] || die "${function_name} function was not defined" } +generate_dockerfile() { + dir="$1" + + readonly install_go=" +ADD https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz /tmp +RUN tar -C /usr/ -xzf /tmp/go${GO_VERSION}.linux-amd64.tar.gz +ENV GOROOT=/usr/go +ENV PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin +" + + readonly dockerfile_template="Dockerfile.in" + [ -d "${dir}" ] || die "${dir}: not a directory" + pushd ${dir} + [ -f "${dockerfile_template}" ] || die "${dockerfile_template}: file not found" + set -x + sed \ + -e "s|@OS_VERSION@|${OS_VERSION}|g" \ + -e "s|@INSTALL_GO@|${install_go//$'\n'/\\n}|g" \ + ${dockerfile_template} > Dockerfile + set +x + popd +} + while getopts c:hr: opt do @@ -110,6 +136,7 @@ check_function_exist "build_rootfs" if [ -n "${USE_DOCKER}" ] ; then image_name="${distro}-rootfs-osbuilder" + generate_dockerfile "${distro_config_dir}" docker build \ --build-arg http_proxy="${http_proxy}" \ --build-arg https_proxy="${https_proxy}" \ diff --git a/rootfs-builder/template/Dockerfile.template b/rootfs-builder/template/Dockerfile.template new file mode 100644 index 0000000000..87c9b9fdaf --- /dev/null +++ b/rootfs-builder/template/Dockerfile.template @@ -0,0 +1,11 @@ +#@distro@: docker image to be used to create a rootfs +#@OS_VERSION@: Docker image version to build this dockerfile +from @distro@:@OS_VERSION@ + +# This dockerfile needs to provide all the componets need to build a rootfs +# Install any package need to create a rootfs (package manager, extra tools) + +# RUN commands + +# This will install the proper golang to build Kata components +@INSTALL_GO@ diff --git a/rootfs-builder/template/Makefile b/rootfs-builder/template/Makefile index 66e04e323a..4315f6da29 100644 --- a/rootfs-builder/template/Makefile +++ b/rootfs-builder/template/Makefile @@ -13,3 +13,8 @@ endif mkdir -p $(DESTDIR) cp "$(MK_DIR)/rootfs_lib_template.sh" "$(DESTDIR)/rootfs_lib.sh" cp "$(MK_DIR)/config_template.sh" "$(DESTDIR)/config.sh" + sed \ + -e "s|@distro@|$(ROOTFS_BASE_NAME)|g" \ + Dockerfile.template > $(DESTDIR)/Dockerfile.in + + diff --git a/rootfs-builder/versions.txt b/rootfs-builder/versions.txt new file mode 100644 index 0000000000..07aa190219 --- /dev/null +++ b/rootfs-builder/versions.txt @@ -0,0 +1 @@ +GO_VERSION=1.9.2 diff --git a/tests/image_creation.bats b/tests/image_creation.bats index 0261fd9931..e018ea15a3 100644 --- a/tests/image_creation.bats +++ b/tests/image_creation.bats @@ -45,5 +45,9 @@ function build_image() } @test "Can create euleros image" { + if [ "$TRAVIS" = true ] + then + skip "travis timout, see: https://github.com/kata-containers/osbuilder/issues/46" + fi build_image euleros } From 45d4e5fb625f877c237898b89ce9929b72e9acb0 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Fri, 26 Jan 2018 11:04:57 -0600 Subject: [PATCH 5/5] travis: Wait more than 10 min Use travis configuration to wait more than 10 min Signed-off-by: Jose Carlos Venegas Munoz --- .travis.yml | 2 +- rootfs-builder/rootfs.sh | 2 -- tests/image_creation.bats | 4 ---- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index b81698ebe4..303d4c4a6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,4 +16,4 @@ before_script: - ".ci/setup.sh" script: -- ".ci/run.sh" +- "travis_wait .ci/run.sh" diff --git a/rootfs-builder/rootfs.sh b/rootfs-builder/rootfs.sh index b8ab4473c8..0175d72940 100755 --- a/rootfs-builder/rootfs.sh +++ b/rootfs-builder/rootfs.sh @@ -96,12 +96,10 @@ ENV PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin [ -d "${dir}" ] || die "${dir}: not a directory" pushd ${dir} [ -f "${dockerfile_template}" ] || die "${dockerfile_template}: file not found" - set -x sed \ -e "s|@OS_VERSION@|${OS_VERSION}|g" \ -e "s|@INSTALL_GO@|${install_go//$'\n'/\\n}|g" \ ${dockerfile_template} > Dockerfile - set +x popd } diff --git a/tests/image_creation.bats b/tests/image_creation.bats index e018ea15a3..0261fd9931 100644 --- a/tests/image_creation.bats +++ b/tests/image_creation.bats @@ -45,9 +45,5 @@ function build_image() } @test "Can create euleros image" { - if [ "$TRAVIS" = true ] - then - skip "travis timout, see: https://github.com/kata-containers/osbuilder/issues/46" - fi build_image euleros }