diff options
Diffstat (limited to 'tools/docker/test-containers/dpdk-forwarding-pods/vpp')
-rw-r--r-- | tools/docker/test-containers/dpdk-forwarding-pods/vpp/Dockerfile | 43 | ||||
-rwxr-xr-x | tools/docker/test-containers/dpdk-forwarding-pods/vpp/get-vpp.sh | 106 |
2 files changed, 149 insertions, 0 deletions
diff --git a/tools/docker/test-containers/dpdk-forwarding-pods/vpp/Dockerfile b/tools/docker/test-containers/dpdk-forwarding-pods/vpp/Dockerfile new file mode 100644 index 00000000..1d7d0862 --- /dev/null +++ b/tools/docker/test-containers/dpdk-forwarding-pods/vpp/Dockerfile @@ -0,0 +1,43 @@ +# Build with latest VPP release +# docker build -t vpp . +# Build with stable VPP 20.05 +# docker build --build-arg REPO='2005' -t vpp . +# Build with exact VPP version +# docker build --build-arg REPO='master' --build-arg VPP_VERSION='20.09-rc0~174-gbfeae8c57' -t vpp . +# Build with specific VPP commit +# docker build --build-arg REPO='master' --build-arg VPP_VERSION='20.09-rc0~[^ ]*-g<commit>' -t vpp . + +# Post-Build +#vpp_version=$(docker run --rm $IMAGE_NAME cat /vpp/version) +#vpp_release=$(echo $vpp_version | cut -d~ -f1) +#vpp_commit=$(echo $vpp_version | sed -r 's/.*-g([0-9a-f]+).*/\1/') +#VPP_VERSION=$(docker run --rm $IMAGE_NAME cat /vpp/version | cut -d~ -f1,2 | sed -e 's/~/./g') + +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg \ + iproute2 \ + iputils-ping \ + && rm -rf /var/lib/apt/lists/* + +ARG REPO +ARG VPP_VERSION + +WORKDIR /vpp + +COPY get-vpp.sh /get-vpp.sh + +RUN set -eux; \ + /get-vpp.sh; \ + apt-get update && apt-get install -y -V ./*.deb; \ + dpkg-query -f '${Version}\n' -W vpp > /vpp/version; \ + rm -rf vom*.deb vpp-dbg*.deb; \ + rm -rf /var/lib/apt/lists/*; + +RUN mkdir -p /var/log/vpp + +CMD ["/usr/bin/vpp", "-c", "/etc/vpp/startup.conf"] diff --git a/tools/docker/test-containers/dpdk-forwarding-pods/vpp/get-vpp.sh b/tools/docker/test-containers/dpdk-forwarding-pods/vpp/get-vpp.sh new file mode 100755 index 00000000..5f57b7b6 --- /dev/null +++ b/tools/docker/test-containers/dpdk-forwarding-pods/vpp/get-vpp.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +[ -z "$REPO_URL" ] && REPO_URL="https://packagecloud.io/install/repositories/fdio/${REPO:=release}" + +# the code below comes from FDio's CSIT project. +function get_vpp () { + # Get and/or install Ubuntu VPP artifacts from packagecloud.io. + # + # Variables read: + # - REPO_URL - FD.io Packagecloud repository. + # - VPP_VERSION - VPP version. + # - INSTALL - If install packages or download only. Default: download + + ls "*.deb" 2>/dev/null && { die "remove existing *.deb files"; } + + set -exuo pipefail + trap '' PIPE + + curl -sS "${REPO_URL}"/script.deb.sh | bash || { + die "Packagecloud FD.io repo fetch failed." + } + + # If version is set we will add suffix. + artifacts=() + both_quotes='"'"'" + match="[^${both_quotes}]*" + qmatch="[${both_quotes}]\?" + sed_command="s#.*apt_source_path=${qmatch}\(${match}\)${qmatch}#\1#p" + apt_fdio_repo_file=$(curl -s "${REPO_URL}"/script.deb.sh | \ + sed -n ${sed_command}) || { + die "Local fdio repo file path fetch failed." + } + + if [ ! -f ${apt_fdio_repo_file} ]; then + die "${apt_fdio_repo_file} not found, \ + repository installation was not successful." + fi + + packages=$(apt-cache -o Dir::Etc::SourceList=${apt_fdio_repo_file} \ + -o Dir::Etc::SourceParts=${apt_fdio_repo_file} dumpavail \ + | grep Package: | cut -d " " -f 2) || { + die "Retrieval of available VPP packages failed." + } + if [ -z "${VPP_VERSION-}" ]; then + allVersions=$(apt-cache -o Dir::Etc::SourceList=${apt_fdio_repo_file} \ + -o Dir::Etc::SourceParts=${apt_fdio_repo_file} \ + show vpp | grep Version: | cut -d " " -f 2) || { + die "Retrieval of available VPP versions failed." + } + if [ "${REPO}" != "master" ]; then + nonRcVersions=$(echo "$allVersions" | grep -v "\-rc[0-9]") || true + [ -n "${nonRcVersions}" ] && allVersions=$nonRcVersions + fi + VPP_VERSION=$(echo "$allVersions" | head -n1) || true + fi + + set +x + echo "Finding packages with version: ${VPP_VERSION-}" + for package in ${packages}; do + # Filter packages with given version + pkg_info=$(apt-cache show -- ${package}) || { + die "apt-cache show on ${package} failed." + } + ver=$(echo ${pkg_info} | grep -o "Version: ${VPP_VERSION-}[^ ]*" | head -1) || true + if [ -n "${ver-}" ]; then + if [ "${package}" == "vom" ]; then + echo " x '${package}' skipped" + else + echo "+++'${package}' found" + ver=$(echo "$ver" | cut -d " " -f 2) + artifacts+=(${package[@]/%/=${ver-}}) + fi + else + echo " - '${package}'" + fi + done + set -x + + if [ "${INSTALL:-false}" = true ]; then + apt-get -y install "${artifacts[@]}" || { + die "Install VPP artifacts failed." + } + else + apt-get -y download "${artifacts[@]}" || { + die "Download VPP artifacts failed." + } + fi +} + +function die () { + # Print the message to standard error end exit with error code specified + # by the second argument. + # + # Hardcoded values: + # - The default error message. + # Arguments: + # - ${1} - The whole error message, be sure to quote. Optional + # - ${2} - the code to exit with, default: 1. + + set -x + set +eu + echo "${1:-Unspecified run-time error occurred!}" + exit "${2:-1}" +} + +get_vpp |