Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed nmos-node docker to BCS req - draft #55

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ RUN \

VOLUME ["/var/run/imtl", "/var/run/mcm", "/workspace"]
COPY --chown=tiber --from=build-stage /buildout/ /
COPY --chown=tiber --chmod=755 --from=build-stage /usr/lib64/libbpf.so.1 /usr/local/lib

RUN ldconfig

Expand Down
9 changes: 8 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,6 @@ function install_in_docker_enviroment {
IMAGE_TAG="${IMAGE_TAG:-latest}"
cat "${VERSIONS_ENVIRONMENT_FILE:-${SCRIPT_DIR}/versions.env}" > "${SCRIPT_DIR}/.temp.env"

# "${VERSIONS_ENVIRONMENT_FILE}"
docker buildx build "${ENV_PROXY_ARGS[@]}" \
--build-arg VERSIONS_ENVIRONMENT_FILE=".temp.env" \
--build-arg IMAGE_CACHE_REGISTRY="${IMAGE_CACHE_REGISTRY}" \
Expand All @@ -844,6 +843,14 @@ function install_in_docker_enviroment {
--target manager-stage \
"${SCRIPT_DIR}"

cp -r "${SCRIPT_DIR}/gRPC" "${SCRIPT_DIR}/nmos"

docker buildx build \
-t "${IMAGE_REGISTRY}/tiber-broadcast-suite-nmos-node:${IMAGE_TAG}" \
-f "${SCRIPT_DIR}/nmos/Dockerfile" \
--target final-stage \
"${SCRIPT_DIR}/nmos"

docker tag "${IMAGE_REGISTRY}/tiber-broadcast-suite:${IMAGE_TAG}" video_production_image:latest
docker tag "${IMAGE_REGISTRY}/mtl-manager:${IMAGE_TAG}" mtl-manager:latest
}
Expand Down
9 changes: 7 additions & 2 deletions gRPC/config_serialize_deserialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Config, senders, receivers, function, multivi

static int serialize_config_json(const Config &input_config, std::string &output_string){
try {
nlohmann::json config_json = input_config;
Config new_config = input_config;
new_config.receivers[0].payload.type = payload_type::video;
new_config.senders[0].payload.type = payload_type::video;

nlohmann::json config_json = new_config;
//Dump json to string
output_string = config_json.dump();

std::cout << "JSON output string: " << std::endl << output_string << std::endl;
}
catch (const nlohmann::json::parse_error &e) {
std::cout << "JSON parse error: " << e.what() << std::endl;
Expand All @@ -44,6 +48,7 @@ static int serialize_config_json(const Config &input_config, std::string &output
static int deserialize_config_json(Config &output_config, const std::string &input_string){
try {
nlohmann::json config_json = nlohmann::json::parse(input_string);
std::cout << "JSON input string: " << std::endl << input_string << std::endl;
// Deserialize from json to Config
output_config = config_json.get<Config>();
}
Expand Down
164 changes: 164 additions & 0 deletions nmos/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# syntax=docker/dockerfile:1
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(©) 2024 Intel Corporation
# Intel® Tiber™ Broadcast Suite
#
# build stage

FROM ubuntu:22.04 AS build-stage

USER root

SHELL ["/bin/bash", "-ex", "-o", "pipefail", "-c"]

ARG nproc

# Commit f5497129 corresponds to Conan package nmos-cpp/cci.20240223
ENV \
TZ="Europe/Warsaw" \
DEBIAN_FRONTEND="noninteractive" \
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn \
nproc=${nproc:-$(nproc)} \
NMOS_CPP_VERSION=f54971298c47a633969e9e9adac824b56fc08da7

COPY patches/ /home/patches
COPY gRPC/ /home/gRPC

RUN \
apt-get update --fix-missing && \
apt-get install -y --no-install-recommends \
build-essential \
g++ \
git \
curl \
python3 \
python3-pip \
python3-setuptools && \
pip install --upgrade \
cmake \
conan~=2.4

RUN \
echo "**** DOWNLOAD AND INSTALL gRPC v1.58 ****" && \
git clone --branch "v1.58.0" --recurse-submodules --depth 1 --shallow-submodules https://github.com/grpc/grpc /tmp/grpc-source && \
mkdir -p "/tmp/grpc-source/cmake/build" && \
cmake -S "/tmp/grpc-source" -B "/tmp/grpc-source/cmake/build" -DgRPC_BUILD_TESTS=OFF -DgRPC_INSTALL=ON && \
make -C "/tmp/grpc-source/cmake/build" -j$(nproc) && \
make -C "/tmp/grpc-source/cmake/build" install && \
rm -rf /tmp/grpc-source

## Get source for Sony nmos-cpp
WORKDIR /home
RUN \
curl --output - -s -k https://codeload.github.com/sony/nmos-cpp/tar.gz/$NMOS_CPP_VERSION | tar zxvf - -C . && \
mv ./nmos-cpp-${NMOS_CPP_VERSION} ./nmos-cpp

RUN \
patch -d /home/nmos-cpp -p1 -i /home/patches/nmos-cpp.patch

## mDNSResponder 878.260.1 Build and install
RUN \
curl --output - -s -k https://codeload.github.com/apple-oss-distributions/mDNSResponder/tar.gz/mDNSResponder-878.260.1 | tar zxvf - -C . && \
mv ./mDNSResponder-mDNSResponder-878.260.1 ./mDNSResponder && \
patch -d mDNSResponder/ -p1 <nmos-cpp/Development/third_party/mDNSResponder/unicast.patch && \
patch -d mDNSResponder/ -p1 <nmos-cpp/Development/third_party/mDNSResponder/permit-over-long-service-types.patch && \
patch -d mDNSResponder/ -p1 <nmos-cpp/Development/third_party/mDNSResponder/poll-rather-than-select.patch

WORKDIR /home/mDNSResponder/mDNSPosix
RUN \
make os=linux && make os=linux install

## Build Sony nmos-cpp from sources - with workaround to keep latest packages for nmos
## Remember to use the same veriosn of nmos and registry
## First download all packages automatically using conan package manager, than build project
WORKDIR /home/nmos-cpp/Development
RUN \
conan profile detect && \
conan install --requires=nmos-cpp/cci.20240223 --deployer=direct_deploy --build=missing

WORKDIR /home/gRPC
RUN \
cmake -B build && \
make -j$(nproc) -C build

RUN \
mkdir /home/nmos-cpp/Development/build && \
mkdir /home/nmos-cpp/Development/nmos-cpp-node/build && \
cp /home/gRPC/build/libFFmpeg_wrapper_client.a /home/nmos-cpp/Development/build && \
cp /home/gRPC/build/libhw_grpc_proto.a /home/nmos-cpp/Development/build && \
cp /home/gRPC/config_params.hpp /home/nmos-cpp/Development/nmos-cpp-node && \
cp /home/gRPC/FFmpeg_wrapper_client.h /home/nmos-cpp/Development/nmos-cpp-node && \
cp /home/gRPC/build/ffmpeg_cmd_wrap.pb.h /home/nmos-cpp/Development/nmos-cpp-node/build && \
cp /home/gRPC/build/ffmpeg_cmd_wrap.grpc.pb.h /home/nmos-cpp/Development/nmos-cpp-node/build

ENV LIBRARY_PATH=/home/nmos-cpp/Development/build

WORKDIR /home/nmos-cpp/Development/build
RUN \
cmake \
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES:STRING="third_party/cmake/conan_provider.cmake" \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE:STRING="MinSizeRel" \
-DCMAKE_CONFIGURATION_TYPES:STRING="MinSizeRel" \
-DCXXFLAGS:STRING="-Os" \
-DNMOS_CPP_USE_AVAHI:BOOL="0" \
/home/nmos-cpp/Development/build .. && \
make -j$(nproc) && \
cp ./nmos-cpp-node /home

## Move executables, libraries and clean up container as much as possible
WORKDIR /home
RUN \
rm -rf .git nmos-cpp

## Re-build container for optimised runtime environment using clean Ubuntu Bionic release
FROM ubuntu:22.04 AS final-stage

ENV \
DEBIAN_FRONTEND="noninteractive"

##Copy required files from build container
COPY --from=build-stage /home /home

##Update container with latest patches and needed packages
RUN apt-get update && \
apt-get install -y --no-install-recommends \
make \
curl \
gnupg

WORKDIR /home/mDNSResponder/mDNSPosix
RUN \
make os=linux install

WORKDIR /home
RUN \
curl -sS -k "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x77b7346a59027b33c10cafe35e64e954262c4500" | apt-key add - && \
echo "deb http://ppa.launchpad.net/mosquitto-dev/mosquitto-ppa/ubuntu jammy main" | tee /etc/apt/sources.list.d/mosquitto.list && \
apt-get update && apt-get install -y --no-install-recommends mosquitto libc6 && \
apt-get remove --purge -y make gnupg && \
apt-get autoremove -y && \
apt-get clean -y --no-install-recommends && \
apt-get autoclean -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /usr/share/doc/ && rm -rf /usr/share/man/ && rm -rf /usr/share/locale/ && \
rm -rf /usr/local/share/man/* && rm -rf /usr/local/share/.cache/* \
rm -rf /home/mDNSResponder /etc/nsswitch.conf.pre-mdns

##Copy entrypoint.sh script and master config to image
COPY entrypoint.sh /home/

##Set script to executable
RUN chmod +x /home/entrypoint.sh

##Expose correct default ports to allow quick publishing
#EXPOSE 8010 8011 11000 11001 1883 5353/udp

HEALTHCHECK --interval=30s --timeout=5s CMD ps aux | grep "nmos-cpp-node" || exit 1

USER "nmos"

WORKDIR /home/
ENTRYPOINT ["/home/entrypoint.sh"]
22 changes: 22 additions & 0 deletions nmos/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Config file processing procedures
sed_escape() {
sed -e 's/[]\/$*.^[]/\\&/g'
}

if [ $# -gt 0 ]; then
if [ -f "$1" ]; then
echo "Reading configuration from $1"
export node_json="$1"
else
exec "$@"
fi
fi

echo -e "\nStarting NMOS Node with following config"
cat $node_json
/home/nmos-cpp-node $node_json
ret=$?

exit $ret # Make sure we really exit
Loading