Skip to content

Commit

Permalink
Add VPP date-plane app TARGETS
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyzhai committed Jun 27, 2024
1 parent 9220af1 commit 59e1c80
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 3 deletions.
82 changes: 79 additions & 3 deletions dash-pipeline/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path))

# "All" type targets for convenience
all:p4 sai saithrift-server docker-saithrift-client docker-saichallenger-client test
all:p4 sai saithrift-server docker-saithrift-client docker-saichallenger-client vpp test

run-all-tests:run-libsai-test run-saithrift-client-tests run-saichallenger-tests
run-saithrift-client-tests: run-saithrift-ptftests run-saithrift-pytests
run-saithrift-client-dev-tests: run-saithrift-dev-ptftests run-saithrift-dev-pytests

.PHONY:clean
clean: kill-all p4-clean sai-clean test-clean network-clean saithrift-server-clean
clean: kill-all p4-clean sai-clean test-clean network-clean saithrift-server-clean vpp-clean
rm -rf $(P4_OUTDIR)

kill-all: kill-saithrift-server kill-switch undeploy-ixiac kill-saichallenger-client
kill-all: kill-saithrift-server kill-switch undeploy-ixiac kill-saichallenger-client kill-vpp

PWD := $(realpath $(mkfile_dir))
DASH_USER ?=dashuser
Expand Down Expand Up @@ -64,6 +64,10 @@ include dockerfiles/DOCKER_SAI_CHALLENGER_CLIENT_BLDR_IMG.env
# SAIChallenger Client image built locally with saithrift client libs + PTF & Pytest frameworks
DOCKER_SAI_CHALLENGER_CLIENT_IMG ?= local/dash-saichallenger-client:latest

# Run/compile vpp
# include file defines DOCKER_VPP_IMG
include dockerfiles/DOCKER_VPP_IMG.env

# Set differently in CI scripts as needed, e.g. run switch container in -d mode
DOCKER_FLAGS ?=-it

Expand Down Expand Up @@ -251,6 +255,49 @@ run-saithrift-bldr-bash:
$(DOCKER_RUN_SAITHRIFT_BLDR) \
/bin/bash

######################################
# VPP date-plane app TARGETS
######################################
DOCKER_RUN_VPP = docker run\
$(DOCKER_FLAGS) \
-v $(PWD)/bmv2:/bmv2 \
-v $(PWD)/tests:/tests \
-v $(PWD)/../:/dash \
--network=host \
-u $(HOST_USER):$(HOST_GROUP) \
--rm \

.PHONY:vpp vpp-clean
vpp-clean:
$(DOCKER_RUN_VPP) \
--name dash-vpp-$(USER) \
-w /dash/dash-pipeline/vpp-plugin $(DOCKER_VPP_IMG) \
make clean

vpp:
@echo "Compile vpp for date-plane app ..."
$(DOCKER_RUN_VPP) \
--name dash-vpp-$(USER) \
-w /dash/dash-pipeline/vpp-plugin $(DOCKER_VPP_IMG) \
make

run-vpp-bash:
$(DOCKER_RUN_VPP) \
--name dash-vpp-$(USER) \
-w /dash/dash-pipeline/vpp-plugin $(DOCKER_VPP_IMG) \
/bin/bash

run-vpp:
$(DOCKER_RUN_VPP) \
--privileged \
-u root \
--name dash-vpp-$(USER) \
-w /dash/dash-pipeline/vpp-plugin $(DOCKER_VPP_IMG) \
./vpp.sh

kill-vpp:
-docker kill dash-vpp-$(USER)

######################################
# P4 Behavioral-model (switch) TARGETS
######################################
Expand Down Expand Up @@ -621,6 +668,35 @@ docker-publish-dash-grpc:
docker push $(DOCKER_GRPC_IMG)
[ -n $(DOCKER_GRPC_IMG_CTAG) ] && docker push $(DOCKER_GRPC_IMG_NAME):$(DOCKER_GRPC_IMG_CTAG)

###############################

DOCKER_VPP_IMG_TAG = $(shell cat dockerfiles/Dockerfile.vpp | $(SHA1SUM))
DOCKER_VPP_IMG = $(DOCKER_VPP_IMG_NAME):$(DOCKER_VPP_IMG_TAG)

docker-dash-vpp:
{ [ x$(ENABLE_DOCKER_PULL) == xy ] && docker pull $(DOCKER_VPP_IMG); } || \
docker build \
-f dockerfiles/Dockerfile.vpp \
-t $(DOCKER_VPP_IMG) \
--build-arg user=$(DASH_USER) \
--build-arg group=$(DASH_GROUP) \
--build-arg uid=$(DASH_UID) \
--build-arg guid=$(DASH_GUID) \
--build-arg hostname=$(DASH_HOST) \
--build-arg available_processors=$(shell nproc) \
dockerfiles
[ -n $(DOCKER_VPP_IMG_CTAG) ] && \
docker tag $(DOCKER_VPP_IMG) $(DOCKER_VPP_IMG_NAME):$(DOCKER_VPP_IMG_CTAG)

docker-pull-dash-vpp:
docker pull $(DOCKER_VPP_IMG)

docker-publish-dash-vpp:
@echo "Publish $(DOCKER_VPP_IMG) - requires credentials, can only do from DASH repo, not a fork"
docker push $(DOCKER_VPP_IMG)
[ -n $(DOCKER_VPP_IMG_CTAG) ] && \
docker push $(DOCKER_VPP_IMG_NAME):$(DOCKER_VPP_IMG_CTAG)

###############################
# BMV2-PKTGEN NETWORKING TARGETS
###############################
Expand Down
5 changes: 5 additions & 0 deletions dash-pipeline/dockerfiles/DOCKER_VPP_IMG.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Define docker image repo/name:tag
# Changing this will cause build/publish to occur in CI actions
export DASH_ACR_REGISTRY=sonicdash.azurecr.io
export DOCKER_VPP_IMG_NAME?=${DASH_ACR_REGISTRY}/dash-vpp-bldr
export DOCKER_VPP_IMG_CTAG?=240118
59 changes: 59 additions & 0 deletions dash-pipeline/dockerfiles/Dockerfile.vpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This Dockerfile builds an image used to compile vpp for dash date-plane app.
FROM amd64/ubuntu:20.04
LABEL maintainer="SONIC-DASH Community"
LABEL description="DASH date-plane app using vpp"

# Configure make to run as many parallel jobs as cores available
ARG available_processors
ARG MAKEFLAGS=-j$available_processors

ARG CC=gcc
ARG CXX=g++
# Set TZ to avoid interactive installer
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV GIT_SSL_NO_VERIFY=true

RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
build-essential \
autoconf \
libtool \
pkg-config \
sudo \
iproute2 net-tools iputils-ping \
make

## Install vpp
RUN apt-get install -y curl
RUN curl -s https://packagecloud.io/install/repositories/fdio/release/script.deb.sh | bash -x
RUN apt-get update && \
apt-get install -y --no-install-recommends \
vpp vpp-plugin-core vpp-plugin-dpdk vpp-dbg vpp-dev

# vpp development environment
RUN echo "wireshark-common wireshark-common/install-setuid boolean true" | debconf-set-selections
WORKDIR /var
RUN (git clone https://gerrit.fd.io/r/vpp && \
cd vpp && UNATTENDED=y make install-dep)


WORKDIR /

ARG user
ARG uid
ARG group
ARG guid
ARG hostname

ENV BUILD_HOSTNAME $hostname
ENV USER $user

RUN groupadd -f -r -g $guid $group
RUN useradd $user -l -u $uid -g $guid -d /var/$user -m -s /bin/bash
RUN echo "$user ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers

USER $user

CMD /bin/bash

0 comments on commit 59e1c80

Please sign in to comment.