diff --git a/.dockerignore b/.dockerignore index 0fbea72603..0ece86ae89 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,4 +10,6 @@ examples/ k8s/ cmd/agentctl/agentctl cmd/vpp-agent/vpp-agent -cmd/vpp-agent-ctl/vpp-agent-ctl \ No newline at end of file +cmd/vpp-agent-ctl/vpp-agent-ctl +docker/dev/build.sh +docker/prod/build.sh \ No newline at end of file diff --git a/Makefile b/Makefile index 4d0101edf5..09cdcc82e3 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,3 @@ -include vpp.env - VERSION ?= $(shell git describe --always --tags --dirty) COMMIT ?= $(shell git rev-parse HEAD) DATE ?= $(shell git log -1 --format="%ct" | xargs -I{} date -d @{} +'%Y-%m-%dT%H:%M%:z') @@ -7,6 +5,8 @@ DATE ?= $(shell git log -1 --format="%ct" | xargs -I{} date -d @{} +'%Y-%m-%d CNINFRA := github.com/ligato/vpp-agent/vendor/github.com/ligato/cn-infra/agent LDFLAGS = -X $(CNINFRA).BuildVersion=$(VERSION) -X $(CNINFRA).CommitHash=$(COMMIT) -X $(CNINFRA).BuildDate=$(DATE) +include vpp.env + ifeq ($(NOSTRIP),) LDFLAGS += -w -s endif @@ -22,39 +22,32 @@ endif COVER_DIR ?= /tmp -# Build all build: cmd examples -# Clean all clean: clean-cmd clean-examples -# Install commands agent: @echo "=> installing agent ${VERSION}" @go install -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} ./cmd/vpp-agent -# Install commands install: @echo "=> installing commands ${VERSION}" go install -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} ./cmd/vpp-agent go install -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} ./cmd/vpp-agent-ctl go install -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} ./cmd/agentctl -# Build commands cmd: @echo "=> building commands ${VERSION}" cd cmd/vpp-agent && go build -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} cd cmd/vpp-agent-ctl && go build -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} cd cmd/agentctl && go build -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} -# Clean commands clean-cmd: @echo "=> cleaning command binaries" rm -f ./cmd/vpp-agent/vpp-agent rm -f ./cmd/vpp-agent-ctl/vpp-agent-ctl rm -f ./cmd/agentctl/agentctl -# Build examples examples: @echo "=> building examples" cd examples/custom_model && go build -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} @@ -72,7 +65,6 @@ examples: cd examples/localclient_vpp/nat && go build -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} cd examples/localclient_vpp/plugins && go build -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} -# Clean examples clean-examples: @echo "=> cleaning examples" cd examples/custom_model && go clean @@ -90,12 +82,14 @@ clean-examples: cd examples/localclient_vpp/nat && go clean cd examples/localclient_vpp/plugins && go clean -# Run tests +# ------------------------------- +# Testing +# ------------------------------- + test: @echo "=> running unit tests" go test -tags="${GO_BUILD_TAGS}" ./... -# Run coverage report test-cover: @echo "=> running unit tests with coverage" go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/coverage.out ./... @@ -109,23 +103,30 @@ test-cover-xml: test-cover gocov convert ${COVER_DIR}/coverage.out | gocov-xml > ${COVER_DIR}/coverage.xml @echo "=> coverage report generated into ${COVER_DIR}/coverage.xml" -# Code generation +perf: + @echo "=> running perf test" + ./tests/perf/grpc-perf/test.sh 1000 + +perf-all: + @echo "=> running all perf tests" + ./tests/perf/run_all.sh + +# ------------------------------- +# Code generation +# ------------------------------- + generate: generate-proto generate-binapi generate-desc-adapters -# Get generator tools get-proto-generators: @go install ./vendor/github.com/gogo/protobuf/protoc-gen-gogo -# Generate proto models generate-proto: get-proto-generators @echo "=> generating proto" ./scripts/genprotos.sh -# Get generator tools get-binapi-generators: @go install ./vendor/git.fd.io/govpp.git/cmd/binapi-generator -# Generate binary api generate-binapi: get-binapi-generators @echo "=> generating binapi" cd plugins/vpp/binapi && go generate ./... @@ -133,6 +134,12 @@ generate-binapi: get-binapi-generators find plugins/vpp/binapi -maxdepth 2 -type f -name '*.patch' -exec patch --no-backup-if-mismatch -p1 -i {} \; @echo +verify-binapi: + @echo "=> verifying binary api" + docker build -f docker/dev/Dockerfile \ + --build-arg VPP_IMG=${VPP_IMG} \ + --target verify-binapi . + get-desc-adapter-generator: @go install ./plugins/kvscheduler/descriptor-adapter @@ -153,13 +160,6 @@ generate-desc-adapters: get-desc-adapter-generator cd plugins/vpp/srplugin && go generate @echo -verify-binapi: - @echo "=> verifying binary api" - docker build -f docker/dev/Dockerfile \ - --build-arg VPP_REPO_URL=${VPP_REPO_URL} \ - --build-arg VPP_COMMIT=${VPP_COMMIT} \ - --target verify-stage . - get-bindata: go get -v github.com/jteeuwen/go-bindata/... go get -v github.com/elazarl/go-bindata-assetfs/... @@ -167,29 +167,32 @@ get-bindata: bindata: get-bindata cd plugins/restplugin && go generate -# Get dependency manager tool +# ------------------------------- +# Dependencies +# ------------------------------- + get-dep: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh dep version -# Install the project's dependencies dep-install: get-dep @echo "=> installing project's dependencies" dep ensure -v -# Update the locked versions of all dependencies dep-update: get-dep @echo "=> updating all dependencies" dep ensure -update -# Check state of dependencies dep-check: get-dep @echo "=> checking dependencies" dep check +# ------------------------------- +# Linters +# ------------------------------- + LINTER := $(shell command -v gometalinter 2> /dev/null) -# Get linter tools get-linters: ifndef LINTER @echo "=> installing linters" @@ -197,52 +200,36 @@ ifndef LINTER gometalinter --install endif -# Run linters lint: get-linters @echo "=> running code analysis" ./scripts/static_analysis.sh golint vet -# Format code format: @echo "=> formatting the code" ./scripts/gofmt.sh MDLINKCHECK := $(shell command -v markdown-link-check 2> /dev/null) -# Get link check tool get-linkcheck: ifndef MDLINKCHECK sudo apt-get update && sudo apt-get install -y npm npm install -g markdown-link-check@3.6.2 endif -# Validate links in markdown files check-links: get-linkcheck ./scripts/check_links.sh -# Travis -travis: - @echo "=> TRAVIS: $$TRAVIS_BUILD_STAGE_NAME" - @echo "Build: #$$TRAVIS_BUILD_NUMBER ($$TRAVIS_BUILD_ID)" - @echo "Job: #$$TRAVIS_JOB_NUMBER ($$TRAVIS_JOB_ID)" - @echo "AllowFailure: $$TRAVIS_ALLOW_FAILURE TestResult: $$TRAVIS_TEST_RESULT" - @echo "Type: $$TRAVIS_EVENT_TYPE PullRequest: $$TRAVIS_PULL_REQUEST" - @echo "Repo: $$TRAVIS_REPO_SLUG Branch: $$TRAVIS_BRANCH" - @echo "Commit: $$TRAVIS_COMMIT" - @echo "$$TRAVIS_COMMIT_MESSAGE" - @echo "Range: $$TRAVIS_COMMIT_RANGE" - @echo "Files:" - @echo "$$(git diff --name-only $$TRAVIS_COMMIT_RANGE)" - -# Install yamllint get-yamllint: pip install --user yamllint -# Lint the yaml files yamllint: get-yamllint @echo "=> linting the yaml files" yamllint -c .yamllint.yml $(shell git ls-files '*.yaml' '*.yml' | grep -v 'vendor/') +# ------------------------------- +# Images +# ------------------------------- + images: dev-image prod-image dev-image: @@ -251,13 +238,21 @@ dev-image: prod-image: ./docker/prod/build.sh -perf: - @echo "=> running perf test" - ./tests/perf/grpc-perf/test.sh 1000 +# ------------------------------- + +travis: + @echo "=> TRAVIS: $$TRAVIS_BUILD_STAGE_NAME" + @echo "Build: #$$TRAVIS_BUILD_NUMBER ($$TRAVIS_BUILD_ID)" + @echo "Job: #$$TRAVIS_JOB_NUMBER ($$TRAVIS_JOB_ID)" + @echo "AllowFailure: $$TRAVIS_ALLOW_FAILURE TestResult: $$TRAVIS_TEST_RESULT" + @echo "Type: $$TRAVIS_EVENT_TYPE PullRequest: $$TRAVIS_PULL_REQUEST" + @echo "Repo: $$TRAVIS_REPO_SLUG Branch: $$TRAVIS_BRANCH" + @echo "Commit: $$TRAVIS_COMMIT" + @echo "$$TRAVIS_COMMIT_MESSAGE" + @echo "Range: $$TRAVIS_COMMIT_RANGE" + @echo "Files:" + @echo "$$(git diff --name-only $$TRAVIS_COMMIT_RANGE)" -perf-all: - @echo "=> running all perf tests" - ./tests/perf/run_all.sh .PHONY: build clean \ install cmd examples clean-examples test \ @@ -266,7 +261,7 @@ perf-all: get-dep dep-install dep-update dep-check \ get-linters lint format \ get-linkcheck check-links \ - travis \ get-yamllint yamllint \ images dev-image prod-image \ - perf perf-all + perf perf-all \ + travis diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index 91049cc0be..33dfaa4f92 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -1,22 +1,12 @@ -ARG BASE_IMG +ARG VPP_IMG=ligato/vpp-base:1904 +FROM ${VPP_IMG} AS vppimg -FROM golang as verify-stage +FROM golang:1.11 AS verify-binapi RUN apt-get update \ && apt-get install -y --no-install-recommends \ - patch python3-pip python3 \ - && rm -rf /var/lib/apt/lists/* \ - && pip3 install ply - -ARG VPP_REPO_URL -ARG VPP_COMMIT - -RUN git clone ${VPP_REPO_URL} /opt/vpp \ - && cd /opt/vpp \ - && git checkout ${VPP_COMMIT} - -COPY scripts/genjsonapi.sh /opt/genjsonapi.sh -RUN /opt/genjsonapi.sh + patch \ + && rm -rf /var/lib/apt/lists/* WORKDIR /go/src/github.com/ligato/vpp-agent @@ -24,102 +14,84 @@ COPY plugins/vpp/binapi plugins/vpp/binapi COPY vendor vendor COPY Makefile vpp.env ./ +COPY --from=vppimg /usr/share/vpp /usr/share/vpp +COPY --from=vppimg /vpp/version /vpp/version + RUN cp -r plugins/vpp/binapi /tmp/orig_binapi \ && make generate-binapi \ - && diff -r plugins/vpp/binapi /tmp/orig_binapi + && diff -r plugins/vpp/binapi /tmp/orig_binapi \ + || ( echo "Generated binapi code does not match with VPP version: `cat /vpp/version`!"; exit 1 ) -FROM ${BASE_IMG} as dev-stage +FROM ${VPP_IMG} AS devimg + +RUN echo "VPP version: `cat /vpp/version`" RUN apt-get update \ && apt-get install -y --no-install-recommends \ - autoconf automake build-essential ca-certificates curl gdb git \ - graphviz inetutils-traceroute iproute2 ipsec-tools iputils-ping \ - libapr1 libmbedcrypto1 libmbedtls10 libmbedx509-0 libtool \ - make mc nano netcat python software-properties-common sudo supervisor \ - telnet unzip wget python-cffi python3-cffi \ + build-essential \ + ca-certificates \ + curl \ + git \ + graphviz \ + iproute2 \ + iputils-ping \ + make \ + patch \ + python \ + sudo \ + supervisor \ + unzip \ + wget \ && rm -rf /var/lib/apt/lists/* -# install Protobuf -ARG PROTOC_VERSION=3.6.1 -ARG PROTOC_OS_ARCH=linux_x86_64 -RUN wget -q https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_OS_ARCH}.zip \ - && unzip protoc-${PROTOC_VERSION}-${PROTOC_OS_ARCH}.zip -d protoc3 \ - && mv protoc3/bin/protoc /usr/local/bin \ - && mv protoc3/include/google /usr/local/include \ - && rm -rf protoc-${PROTOC_VERSION}-${PROTOC_OS_ARCH}.zip protoc3 - -RUN mkdir -p /opt/vpp-agent/dev /opt/vpp-agent/plugin - -WORKDIR /opt/vpp-agent/dev - -ARG VPP_REPO_URL -ARG VPP_COMMIT - -ARG VPP_DEBUG_DEB +# Install Go +ENV GOLANG_VERSION 1.11.10 RUN set -eux; \ - git clone "${VPP_REPO_URL}" vpp; \ - cd vpp; \ - git checkout "${VPP_COMMIT}"; \ - sed -i -e 's/vpp vom/vpp/g' build-data/platforms/vpp.mk; \ - export UNATTENDED=y; \ - make install-dep dpdk-install-dev; \ - if [ -n "${VPP_DEBUG_DEB}" ]; then \ - make build; \ - make -C build-root PLATFORM=vpp TAG=vpp_debug install-deb; \ - else \ - make build-release pkg-deb; \ - fi; \ - cd build-root; \ - dpkg -i *.deb; \ - rm -rf .ccache /var/lib/apt/lists/*; \ - find . -type f -name '*.o' -exec rm -rf '{}' \; - -# install Go -ENV GOLANG_VERSION 1.11.8 -ARG GOLANG_OS_ARCH=linux-amd64 -RUN wget -O go.tgz "https://golang.org/dl/go${GOLANG_VERSION}.${GOLANG_OS_ARCH}.tar.gz" \ - && tar -C /usr/local -xzf go.tgz \ - && rm go.tgz + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) goRelArch='linux-amd64'; ;; \ + armhf) goRelArch='linux-armv6l'; ;; \ + arm64) goRelArch='linux-arm64'; ;; \ + esac; \ + wget -qO go.tgz "https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ + tar -C /usr/local -xzf go.tgz; \ + rm go.tgz; ENV GOPATH /go ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH -RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" \ - && chmod -R 777 "$GOPATH" - -# install debugger -RUN \ - go get -u github.com/go-delve/delve/cmd/dlv && dlv version; \ - go get -u github.com/golang/dep/cmd/dep && dep version; -# copy configs -COPY \ - docker/dev/etcd.conf \ - docker/dev/vpp-ifplugin.conf \ - docker/dev/linux-ifplugin.conf \ - docker/dev/logs.conf \ - ./ -COPY docker/dev/vpp.conf /etc/vpp/vpp.conf -COPY docker/dev/supervisord.conf /etc/supervisord/supervisord.conf +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" + +# Install debugger +#RUN \ +# go get -u github.com/go-delve/delve/cmd/dlv && dlv version; \ +# go get -u github.com/golang/dep/cmd/dep && dep version; -# copy scripts +# Copy configs COPY \ - docker/dev/exec_vpp.sh \ - docker/dev/exec_agent.sh \ - docker/dev/supervisord_kill.py \ - /usr/bin/ + ./docker/dev/etcd.conf \ + ./docker/dev/logs.conf \ + ./docker/dev/vpp-ifplugin.conf \ + /opt/vpp-agent/dev/ -ARG VERSION -ARG COMMIT -ARG DATE +COPY ./docker/dev/vpp.conf /etc/vpp/vpp.conf +COPY ./docker/dev/supervisord.conf /etc/supervisord/supervisord.conf +COPY ./docker/dev/supervisord_kill.py /usr/bin/ -# copy & build agent -COPY . $GOPATH/src/github.com/ligato/vpp-agent +# Build agent +WORKDIR $GOPATH/src/github.com/ligato/vpp-agent -RUN cd $GOPATH/src/github.com/ligato/vpp-agent \ - && VERSION=$VERSION COMMIT=$COMMIT DATE=$DATE make install +# this prevents buildkit from skipping verify-binapi stage +COPY --from=verify-binapi $GOPATH/src/github.com/ligato/vpp-agent/plugins/vpp/binapi plugins/vpp/binapi + +COPY . ./ + +ARG VERSION=dev +ARG COMMIT +ARG DATE -WORKDIR / +RUN VERSION=$VERSION COMMIT=$COMMIT DATE=$DATE make install # run supervisor as the default executable CMD rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api && \ diff --git a/docker/dev/build.sh b/docker/dev/build.sh index 3154a0e761..3ce9d31ef2 100755 --- a/docker/dev/build.sh +++ b/docker/dev/build.sh @@ -4,72 +4,28 @@ cd "$(dirname "$0")" set -e -# Before run of this script you can set environmental variables -# IMAGE_TAG, DOCKERFILE, BASE_IMG, GOLANG_OS_ARCH, then export them -# and to use defined values instead of default ones - -IMAGE_TAG=${IMAGE_TAG:-'dev_vpp_agent'} -DOCKERFILE=${DOCKERFILE:-'Dockerfile'} - -BASE_IMG=${BASE_IMG:-'ubuntu:18.04'} - -BUILDARCH=`uname -m` -case "$BUILDARCH" in - "aarch64" ) - GOLANG_OS_ARCH=${GOLANG_OS_ARCH:-'linux-arm64'} - PROTOC_OS_ARCH=${PROTOC_OS_ARCH:-'linux-aarch_64'} - ;; - - "x86_64" ) - # for AMD64 platform is used the default image (without suffix -amd64) - GOLANG_OS_ARCH=${GOLANG_OS_ARCH:-'linux-amd64'} - PROTOC_OS_ARCH=${PROTOC_OS_ARCH:-'linux-x86_64'} - ;; - * ) - echo "Architecture ${BUILDARCH} is not supported." - exit - ;; -esac - - source ../../vpp.env -VPP_DEBUG_DEB=${VPP_DEBUG_DEB:-} VERSION=$(git describe --always --tags --dirty) COMMIT=$(git rev-parse HEAD) DATE=$(git log -1 --format="%ct" | xargs -I{} date -d @{} +'%Y-%m-%dT%H:%M%:z') -echo "==============================" -echo "Building dev image" -echo "==============================" -echo " base image: ${BASE_IMG}" -echo " image tag: ${IMAGE_TAG}" -echo " architecture: ${BUILDARCH}" -echo -echo "-----------------------------" -echo "VPP" -echo "-----------------------------" -echo " repo URL: ${VPP_REPO_URL}" -echo " commit: ${VPP_COMMIT}" -echo -echo "-----------------------------" +echo "===============================================" +echo "Building dev image: ${IMAGE_TAG:=dev_vpp_agent}" +echo "===============================================" +echo " vpp image: ${VPP_IMG}" +echo "-----------------------------------------------" echo "Agent" -echo "-----------------------------" +echo "-----------------------------------------------" echo " version: ${VERSION}" echo " commit: ${COMMIT}" echo " date: ${DATE}" -echo -echo "-----------------------------" +echo "===============================================" -docker build -f ${DOCKERFILE} \ - --tag ${IMAGE_TAG} \ - --build-arg BASE_IMG=${BASE_IMG} \ - --build-arg VPP_COMMIT=${VPP_COMMIT} \ - --build-arg VPP_REPO_URL=${VPP_REPO_URL} \ - --build-arg VPP_DEBUG_DEB=${VPP_DEBUG_DEB} \ - --build-arg GOLANG_OS_ARCH=${GOLANG_OS_ARCH} \ - --build-arg PROTOC_OS_ARCH=${PROTOC_OS_ARCH} \ +docker build -f Dockerfile \ + --build-arg VPP_IMG=${VPP_IMG} \ --build-arg VERSION=${VERSION} \ --build-arg COMMIT=${COMMIT} \ --build-arg DATE=${DATE} \ - ${DOCKER_BUILD_ARGS} ../.. + --tag ${IMAGE_TAG} \ + ${DOCKER_BUILD_ARGS} ../.. diff --git a/docker/dev/exec_agent.sh b/docker/dev/exec_agent.sh deleted file mode 100755 index f6a74b028c..0000000000 --- a/docker/dev/exec_agent.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [ -n "$OMIT_AGENT" ]; then - echo "Start of vpp-agent disabled (unset OMIT_AGENT to enable it)" -else - echo "Starting vpp-agent.." - exec vpp-agent --config-dir=/opt/vpp-agent/dev -fi diff --git a/docker/dev/exec_vpp.sh b/docker/dev/exec_vpp.sh deleted file mode 100755 index 6a524eb67f..0000000000 --- a/docker/dev/exec_vpp.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -e - -VPP_DIR=${VPP_DIR:-/opt/vpp-agent/dev/vpp} - -if [ -n "$RUN_VPP_DEBUG" ]; then - echo "Running VPP in DEBUG mode" - exec ${VPP_DIR}/build-root/install-vpp_debug-native/vpp/bin/vpp -c /etc/vpp/vpp.conf -else - echo "Running VPP in RELEASE mode" - exec ${VPP_DIR}/build-root/install-vpp-native/vpp/bin/vpp -c /etc/vpp/vpp.conf -fi diff --git a/docker/dev/linux-ifplugin.conf b/docker/dev/linux-ifplugin.conf deleted file mode 100644 index 9031308d55..0000000000 --- a/docker/dev/linux-ifplugin.conf +++ /dev/null @@ -1 +0,0 @@ -stopwatch: true \ No newline at end of file diff --git a/docker/dev/supervisord.conf b/docker/dev/supervisord.conf index a8880f034b..d768e417e0 100644 --- a/docker/dev/supervisord.conf +++ b/docker/dev/supervisord.conf @@ -5,13 +5,13 @@ nodaemon=true pidfile=/run/supervisord.pid [program:vpp] -command=/usr/bin/exec_vpp.sh +command=/usr/bin/vpp -c /etc/vpp/vpp.conf autorestart=false redirect_stderr=true priority=1 [program:agent] -command=/usr/bin/exec_agent.sh +command=vpp-agent --config-dir=/opt/vpp-agent/dev startsecs=0 autorestart=false redirect_stderr=true diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 0f4649beaf..0eefe93482 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -1,68 +1,57 @@ -FROM dev_vpp_agent as devimg +ARG DEV_IMG=dev_vpp_agent +FROM ${DEV_IMG} as devimg FROM ubuntu:18.04 as base RUN apt-get update \ && apt-get install -y --no-install-recommends \ - # general tools - inetutils-traceroute \ - iproute2 \ - iputils-ping \ - # vpp requirements - ca-certificates \ - libapr1 \ - libc6 \ - libmbedcrypto1 \ - libmbedtls10 \ - libmbedx509-0 \ - libnuma1 \ - openssl \ - # other - ipsec-tools \ - python \ - supervisor \ - netcat \ + # general tools + inetutils-traceroute \ + iproute2 \ + iputils-ping \ + # vpp requirements + ca-certificates \ + libapr1 \ + libc6 \ + libmbedcrypto1 \ + libmbedtls10 \ + libmbedx509-0 \ + libnuma1 \ + openssl \ + # other + python \ + supervisor \ && rm -rf /var/lib/apt/lists/* # install vpp COPY --from=devimg \ - /opt/vpp-agent/dev/vpp/build-root/libvppinfra_*.deb \ - /opt/vpp-agent/dev/vpp/build-root/vpp-plugin-core_*.deb \ - /opt/vpp-agent/dev/vpp/build-root/vpp-plugin-dpdk_*.deb \ - /opt/vpp-agent/dev/vpp/build-root/vpp_*.deb \ + /vpp/libvppinfra_*.deb \ + /vpp/vpp-plugin-core_*.deb \ + /vpp/vpp-plugin-dpdk_*.deb \ + /vpp/vpp_*.deb \ /opt/vpp/ RUN cd /opt/vpp/ \ && dpkg -i *.deb \ && rm *.deb +# Final image FROM scratch COPY --from=base / / -# install agent +# Install agent COPY --from=devimg \ + /go/bin/agentctl \ /go/bin/vpp-agent \ - /go/bin/vpp-agent-ctl \ /bin/ -# copy configs -COPY \ - etcd.conf \ - vpp-ifplugin.conf \ - linux-ifplugin.conf \ - /opt/vpp-agent/dev/ - +# Copy configs +COPY etcd.conf /opt/vpp-agent/dev/ COPY vpp.conf /etc/vpp/vpp.conf COPY supervisord.conf /etc/supervisord/supervisord.conf - -# copy scripts -COPY \ - exec_agent.sh \ - supervisord_kill.py \ - /usr/bin/ +COPY supervisord_kill.py /usr/bin/ WORKDIR /root/ -# run supervisor as the default executable CMD rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api && \ exec /usr/bin/supervisord -c /etc/supervisord/supervisord.conf diff --git a/docker/prod/build.sh b/docker/prod/build.sh index 4867a88398..84406c07c6 100755 --- a/docker/prod/build.sh +++ b/docker/prod/build.sh @@ -1,25 +1,22 @@ #!/bin/bash -# Before run of this script you can set environmental variables -# IMAGE_TAG ... then export them -# and to use defined values instead of default ones cd "$(dirname "$0")" set -e -IMAGE_TAG=${IMAGE_TAG:-'prod_vpp_agent'} - -BUILDARCH=`uname -m` -case "$BUILDARCH" in - "aarch64" ) - ;; - - "x86_64" ) - ;; - * ) - echo "Architecture ${BUILDARCH} is not supported." - exit - ;; +buildArch=`uname -m` +case "${buildArch##*-}" in + aarch64) ;; + x86_64) ;; + *) echo "Current architecture (${buildArch}) is not supported."; exit 2; ;; esac -docker build ${DOCKER_BUILD_ARGS} --tag ${IMAGE_TAG} . +echo "===============================================" +echo "Building prod image: ${IMAGE_TAG:=prod_vpp_agent}" +echo "===============================================" +echo " dev image: ${DEV_IMG:=dev_vpp_agent}" +echo "-----------------------------------------------" + +docker build -f Dockerfile \ + --tag ${IMAGE_TAG} \ + ${DOCKER_BUILD_ARGS} . diff --git a/docker/prod/exec_agent.sh b/docker/prod/exec_agent.sh deleted file mode 100755 index f6a74b028c..0000000000 --- a/docker/prod/exec_agent.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [ -n "$OMIT_AGENT" ]; then - echo "Start of vpp-agent disabled (unset OMIT_AGENT to enable it)" -else - echo "Starting vpp-agent.." - exec vpp-agent --config-dir=/opt/vpp-agent/dev -fi diff --git a/docker/prod/linux-ifplugin.conf b/docker/prod/linux-ifplugin.conf deleted file mode 100644 index 9031308d55..0000000000 --- a/docker/prod/linux-ifplugin.conf +++ /dev/null @@ -1 +0,0 @@ -stopwatch: true \ No newline at end of file diff --git a/docker/prod/supervisord.conf b/docker/prod/supervisord.conf index 0be10c28b7..d768e417e0 100644 --- a/docker/prod/supervisord.conf +++ b/docker/prod/supervisord.conf @@ -11,7 +11,7 @@ redirect_stderr=true priority=1 [program:agent] -command=/usr/bin/exec_agent.sh +command=vpp-agent --config-dir=/opt/vpp-agent/dev startsecs=0 autorestart=false redirect_stderr=true diff --git a/docker/prod/vpp-ifplugin.conf b/docker/prod/vpp-ifplugin.conf deleted file mode 100644 index 9031308d55..0000000000 --- a/docker/prod/vpp-ifplugin.conf +++ /dev/null @@ -1 +0,0 @@ -stopwatch: true \ No newline at end of file diff --git a/scripts/install_protobuf.sh b/scripts/install_protobuf.sh new file mode 100644 index 0000000000..3d2ce0de45 --- /dev/null +++ b/scripts/install_protobuf.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +PROTOC_VERSION=3.7.1 +PROTOC_OS_ARCH=linux-x86_64 + +download_url="https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_OS_ARCH}.zip" + +wget -O /tmp/protoc.zip ${download_url} +unzip -o /tmp/protoc.zip -d /tmp/protoc3 +sudo mv /tmp/protoc3/bin/protoc /usr/local/bin +sudo mv /tmp/protoc3/include/google /usr/local/include +rm -rf /tmp/protoc.zip /tmp/protoc3 diff --git a/vpp.env b/vpp.env index 17db391f63..0de5ccecdb 100644 --- a/vpp.env +++ b/vpp.env @@ -2,3 +2,4 @@ VPP_REPO_URL=https://github.com/FDio/vpp.git VPP_COMMIT_1901=0f36ef60d80998983a0502ac3f65b5fa71b8cbc4 # v19.01.1-14-g0f36ef60d VPP_COMMIT_1904=6f05f724f4091acde82ef39e941a1ef819e53893 # v19.04-6-g6f05f724f VPP_COMMIT=${VPP_COMMIT_1904} +VPP_IMG=ligato/vpp-base:1904 \ No newline at end of file