Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from open-ness/openness_rel_2003
Browse files Browse the repository at this point in the history
Openness rel 2003
  • Loading branch information
cjnolan authored Mar 31, 2020
2 parents 84a3af7 + bff3781 commit 6b6a486
Show file tree
Hide file tree
Showing 69 changed files with 5,176 additions and 1,186 deletions.
241 changes: 127 additions & 114 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,137 +1,150 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Intel Corporation
# Copyright (c) 2019-2020 Intel Corporation

export GO111MODULE = on

.PHONY: build appliance eaa interfaceservice edgedns clean build-docker lint test help build-docker-hddl hddllog build-docker-fpga-cfg build-docker-fpga-opae
TMP_DIR:=$(shell mktemp -d)
BUILD_DIR ?=dist
.PHONY: \
onprem-nts onprem-ovncni \
appliance appliance-cni appliance-nts \
run-onprem-nts clean \
eaa edgednssvr nts edalibs ovncni hddllog syslog-ng \
networkedge networkedge-kubeovn \
interfaceservice biosfw fpga-cfg fpga-opae \
lint test help build pull-syslog
COPY_DOCKERFILES := $(shell /usr/bin/cp -rfT ./build/ ./dist/)
VER ?= 1.0
RTE_SDK ?= /opt/dpdk-18.11.2

VER:=1.0
help:
@echo "Please use \`make <target>\` where <target> is one of"
@echo ""
@echo "Build all the required Docker images for OpenNESS' deployment mode:"
@echo " onprem-nts to build components of On-Premises with NTS dataplane (EAA, Edge DNS Service, Appliance, NTS)"
@echo " onprem-ovncni to build components of On-Premises with OVN CNI dataplane (EAA, Edge DNS Service, Appliance)"
@echo " networkedge to build components of Network Edge deployment (EAA, Edge DNS Service)"
@echo " networkedge-kubeovn to build components of Kube-OVN Network Edge deployment (EAA, Edge DNS Service, Interface Service)"
@echo " common-services to build component common for both On-Premises and Network Edge deployments"
@echo ""
@echo "Start On-Premises services:"
@echo " run-onprem-nts to start components of On-Premises with NTS as a dataplane (EAA, Edge DNS Service, Appliance, NTS)"
@echo ""
@echo "Helper targets:"
@echo " clean to clean build artifacts"
@echo " lint to run linter on Go code"
@echo " test to run tests on Go code"
@echo " help to show this message"
@echo " build to build all executables without images"
@echo ""
@echo "Single targets:"
@echo " appliance-nts to build only docker image of the Appliance for NTS dataplane"
@echo " appliance-cni to build only docker image of the Appliance for OVN CNI dataplane"
@echo " eaa to build only docker image of the EAA"
@echo " interfaceservice to build only docker image of the Interface Service"
@echo " edgednssvr to build only docker image of the Edge DNS Service"
@echo " nts to build only docker image of the NTS"
@echo " edalibs to build EDA libs"
@echo " ovncni to build only ovncni executable"
@echo " hddllog to build only docker image of the HDDL Service"
@echo " biosfw to build only docker image of the BIOSFW"
@echo " fpga-cfg to build only docker image of the FPGA Config"
@echo " fpga-opae to build only docker image of the FPGA OPAE"
@echo " syslog-ng to build only docker image of the syslog-ng"
@echo " pull-syslog to pull docker image of the syslog-ng"

common-services: eaa edgednssvr syslog-ng

onprem-nts: common-services appliance-nts

onprem-ovncni: common-services appliance-cni

networkedge: common-services

networkedge-kubeovn: networkedge interfaceservice

run-onprem-nts:
VER=${VER} docker-compose up appliance nts eaa edgednssvr syslog-ng --no-build

ifeq ($(KUBE_OVN_MODE), True)
build: eaa interfaceservice edgedns
else
build: edalibs appliance eaa edgedns nts
endif
clean:
rm -rf ./dist
$(MAKE) clean -C internal/nts
$(MAKE) clean -C internal/nts/eda_libs

lint: edalibs
golangci-lint run --build-tags=nts
golangci-lint run --build-tags=cni

test: edalibs
http_proxy= https_proxy= HTTP_PROXY= HTTPS_PROXY= ginkgo -v -r --randomizeSuites --failOnPending --skipPackage=vendor,edants,wrappers,stubs

appliance-nts: edalibs
$(MAKE) appliance APPLIANCE_MODE=nts

appliance-cni:
$(MAKE) appliance APPLIANCE_MODE=cni

APPLIANCE_MODE ?= nts
appliance:
mkdir -p "${BUILD_DIR}"
GOOS=linux go build -o "${BUILD_DIR}/appliance" ./cmd/appliance
GOOS=linux go build -tags ${APPLIANCE_MODE} -o ./dist/$@/$@ ./cmd/$@
ifndef SKIP_DOCKER_IMAGES
cp ${RTE_SDK}/usertools/dpdk-devbind.py ./dist/$@/
VER=${VER} docker-compose build $@
endif

eaa:
mkdir -p "${BUILD_DIR}"
GOOS=linux go build -o "${BUILD_DIR}/eaa" ./cmd/eaa
GOOS=linux go build -o ./dist/$@/$@ ./cmd/$@
ifndef SKIP_DOCKER_IMAGES
VER=${VER} docker-compose build $@
endif

interfaceservice:
mkdir -p "${BUILD_DIR}"
GOOS=linux go build -o "${BUILD_DIR}/interfaceservice" ./cmd/interfaceservice
GOOS=linux go build -o ./dist/$@/$@ ./cmd/$@
ifndef SKIP_DOCKER_IMAGES
# This 'hack' will enable building without DPDK - ./dpdk-devbind.py will be copied if existing
# but will also not fail if file will be not available
-cp ${RTE_SDK}/usertools/dpdk-devbind.py ./dist/$@/
VER=${VER} docker-compose build $@
endif

edgedns:
mkdir -p "${BUILD_DIR}"
GOOS=linux go build -a --ldflags '-extldflags "-static"' -tags netgo -installsuffix netgo -o "${BUILD_DIR}/edgednssvr" ./cmd/edgednssvr
edgednssvr:
GOOS=linux go build -a --ldflags '-extldflags "-static"' -tags netgo -installsuffix netgo -o ./dist/$@/$@ ./cmd/$@
ifndef SKIP_DOCKER_IMAGES
VER=${VER} docker-compose build $@
endif

syslog-ng:
ifndef SKIP_DOCKER_IMAGES
VER=${VER} docker-compose build $@
endif

nts:
make -C internal/nts
$(MAKE) -C internal/nts
ifndef SKIP_DOCKER_IMAGES
VER=${VER} docker-compose build $@
endif

edalibs:
make -C internal/nts/eda_libs
$(MAKE) -C internal/nts/eda_libs

hddllog:
mkdir -p "${BUILD_DIR}"
GOOS=linux go build -o "${BUILD_DIR}/hddllog" ./cmd/hddllog
ovncni:
GOOS=linux go build -o ./dist/$@/$@ ./cmd/$@

clean:
rm -rf "${BUILD_DIR}"
make clean -C internal/nts
make clean -C internal/nts/eda_libs

build-docker: build
cp docker-compose.yml "${TMP_DIR}"
cp build/eaa/Dockerfile "${TMP_DIR}/Dockerfile_eaa"
cp build/eaa/entrypoint_eaa.sh "${TMP_DIR}"
cp "${BUILD_DIR}/eaa" "${TMP_DIR}"
cp build/edgednssvr/Dockerfile "${TMP_DIR}/Dockerfile_edgednssvr"
cp "${BUILD_DIR}/edgednssvr" "${TMP_DIR}"
ifeq ($(KUBE_OVN_MODE), True)
cp build/interfaceservice/Dockerfile "${TMP_DIR}/Dockerfile_interfaceservice"
cp build/interfaceservice/entrypoint_interfaceservice.sh "${TMP_DIR}"
cp "${BUILD_DIR}/interfaceservice" "${TMP_DIR}"
cd "${TMP_DIR}" && VER=${VER} docker-compose build eaa interfaceservice edgednssvr syslog-ng
else
cp build/appliance/Dockerfile "${TMP_DIR}/Dockerfile_appliance"
cp build/appliance/entrypoint.sh "${TMP_DIR}"
cp /opt/dpdk-18.11.2/usertools/dpdk-devbind.py "${TMP_DIR}"
cp "${BUILD_DIR}/appliance" "${TMP_DIR}"
mkdir -p "${TMP_DIR}/nts"
cp internal/nts/build/nes-daemon "${TMP_DIR}/nts"
cp internal/nts/kni_docker_daemon.py "${TMP_DIR}/nts"
cp internal/nts/ovs_docker_daemon.py "${TMP_DIR}/nts"
cp internal/nts/entrypoint.sh "${TMP_DIR}/nts"
cp internal/nts/build/libnes_api_shared.so "${TMP_DIR}/nts"
cp internal/nts/Dockerfile "${TMP_DIR}/Dockerfile_nts"
cd "${TMP_DIR}" && VER=${VER} docker-compose build appliance nts eaa edgednssvr syslog-ng
endif
ls "${TMP_DIR}"
rm -rf "${TMP_DIR}"

build-docker-hddl: hddllog
cp build/hddlservice/Dockerfile "${TMP_DIR}/Dockerfile_hddlservice"
cp build/hddlservice/start.sh "${TMP_DIR}"
cp build/hddlservice/docker-compose.yml "${TMP_DIR}"
cp "${BUILD_DIR}/hddllog" "${TMP_DIR}"
cd "${TMP_DIR}" && VER=${VER} docker-compose build
ls "${TMP_DIR}"
rm -rf "${TMP_DIR}"

build-docker-biosfw:
cp build/biosfw/Dockerfile "${TMP_DIR}/Dockerfile_biosfw"
cp build/biosfw/biosfw.sh "${TMP_DIR}"
cp build/biosfw/syscfg_package.zip "${TMP_DIR}"
cd "${TMP_DIR}" && docker build -t openness-biosfw -f Dockerfile_biosfw .
rm -rf "${TMP_DIR}"

build-docker-fpga-cfg:
cp build/fpga_config/Dockerfile "${TMP_DIR}/Dockerfile_fpga"
cp -r build/fpga_config/bbdev_config_service "${TMP_DIR}"
cd "${TMP_DIR}" && docker build -t fpga-config-utility:1.0 -f Dockerfile_fpga .
rm -rf "${TMP_DIR}"

build-docker-fpga-opae:
cp build/fpga_opae/Dockerfile "${TMP_DIR}/Dockerfile_opae"
cp -r build/fpga_opae/n3000-1-3-5-beta-cfg-2x2x25g-setup.zip "${TMP_DIR}"
cp -r build/fpga_opae/n3000-1-3-5-beta-rte-setup.zip "${TMP_DIR}"
cp -r build/fpga_opae/expect_script.sh "${TMP_DIR}"
cp -r build/fpga_opae/check_if_modules_loaded.sh "${TMP_DIR}"
cd "${TMP_DIR}" && docker build -t fpga-opae-pacn3000:1.0 -f Dockerfile_opae .
rm -rf "${TMP_DIR}"

run-docker:
ifeq ($(KUBE_OVN_MODE), False)
VER=${VER} docker-compose up appliance nts eaa edgednssvr syslog-ng --no-build
hddllog:
GOOS=linux go build -o ./dist/hddlservice/$@ ./cmd/$@
ifndef SKIP_DOCKER_IMAGES
VER=${VER} docker-compose -f dist/hddlservice/docker-compose.yml build
endif

lint: edalibs
golangci-lint run
biosfw:
docker build -t openness-$@ -f ./dist/$@/Dockerfile ./dist/$@/

test: edalibs
http_proxy= https_proxy= HTTP_PROXY= HTTPS_PROXY= ginkgo -v -r --randomizeSuites --failOnPending --skipPackage=vendor,edants,wrappers,stubs
fpga-cfg:
docker build -t fpga-config-utility:1.0 -f ./dist/fpga_config/Dockerfile ./dist/fpga_config/

help:
@echo "Please use \`make <target>\` where <target> is one of"
@echo " build to build the appliance application, EAA, edgedns server and NTS"
@echo " appliance to build the appliance application"
@echo " interfaceservice to build the interfaceservice"
@echo " eaa to build the EAA"
@echo " edgedns to build the edgedns server"
@echo " nts to build the NTS"
@echo " hddllog to build the log supporting hddl service"
@echo " clean to clean up build artifacts and docker"
@echo " build-docker to build the release docker image"
@echo " build-docker-hddl to build optional docker image for hddl-service"
@echo " build-docker-biosfw to build optional docker image for biosfw feature"
@echo " build-docker-fpga-cfg to build optional docker image for bbdev configuration utility"
@echo " build-docker-fpga-opae to build optional docker image for opae"
@echo " run-docker to start containers"
@echo " lint to run linters and static analysis on the code"
@echo " test to run unit tests"
fpga-opae:
docker build -t fpga-opae-pacn3000:1.0 -f ./dist/fpga_opae/Dockerfile ./dist/fpga_opae/

build:
$(MAKE) SKIP_DOCKER_IMAGES=1 common-services appliance-nts edalibs nts interfaceservice

pull-syslog:
docker-compose pull --quiet syslog-ng
10 changes: 7 additions & 3 deletions build/appliance/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Intel Corporation
# Copyright (c) 2019-2020 Intel Corporation

FROM centos:7.6.1810 AS appliance-deps-image

RUN yum install -y libvirt-devel \
pciutils which \
unbound openssl \
sudo \
epel-release \
python3 \
&& yum clean all
RUN rpm -ivh https://github.com/alauda/ovs/releases/download/v2.11.4-1/openvswitch-2.11.4-1.el7.x86_64.rpm
RUN rpm -ivh https://github.com/alauda/ovs/releases/download/v2.11.4-1/openvswitch-2.11.4-1.el7.x86_64.rpm \
https://github.com/alauda/ovs/releases/download/2.11.4-2/ovn-2.11.4-2.el7.x86_64.rpm \
https://github.com/alauda/ovs/releases/download/2.11.4-2/ovn-common-2.11.4-2.el7.x86_64.rpm

FROM appliance-deps-image

Expand All @@ -27,4 +31,4 @@ COPY ./appliance ./
COPY ./dpdk-devbind.py ./
COPY ./entrypoint.sh ./

CMD ["sudo", "./entrypoint.sh"]
CMD ["sudo", "-E", "./entrypoint.sh"]
8 changes: 4 additions & 4 deletions build/appliance/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env bash

# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Intel Corporation
# Copyright (c) 2019-2020 Intel Corporation

ctrl_cert_path="/host_certs/controller-root-ca.pem"
ctrl_dest_path="/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"

check_if_cert_added() {
python - << END
python3 - << END
import sys
bundle = open('${ctrl_dest_path}').read()
ctrl_cert = open('${ctrl_cert_path}').read()
bundle = open('${ctrl_dest_path}', 'rb').read()
ctrl_cert = open('${ctrl_cert_path}', 'rb').read()
if not ctrl_cert in bundle:
sys.exit(1)
END
Expand Down
5 changes: 4 additions & 1 deletion build/edgednssvr/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Intel Corporation
# Copyright (c) 2019-2020 Intel Corporation

FROM alpine:latest AS edgedns-deps-image

RUN echo -e "http://nl.alpinelinux.org/alpine/v3.11/main\nhttp://nl.alpinelinux.org/alpine/v3.11/community" >> /etc/apk/repositories
RUN apk add --no-cache sudo

FROM edgedns-deps-image
Expand All @@ -14,6 +15,8 @@ ARG user_dir=/home/$username

RUN addgroup -S sudo && adduser -S $username -G sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# Workaround for sudo error: https://gitlab.alpinelinux.org/alpine/aports/issues/11122
RUN echo 'Set disable_coredump false' >> /etc/sudo.conf

USER $username
WORKDIR $user_dir
Expand Down
4 changes: 2 additions & 2 deletions build/fpga_config/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Intel Corporation
# Copyright (c) 2019-2020 Intel Corporation

FROM centos:7.6.1810 AS builder

Expand All @@ -12,7 +12,7 @@ RUN yum install -y git build-essential cmake gcc-c++ make
WORKDIR /root/bbdev_config
COPY bbdev_config_service .

RUN git clone https://github.com/benhoyt/inih
RUN git clone -b r47 https://github.com/benhoyt/inih
RUN cd inih/extra && make -f Makefile.static && cp ../ini.h .
RUN make

Expand Down
Loading

0 comments on commit 6b6a486

Please sign in to comment.