From d0abdd4c04453ad6453eadc687d186f3e59f4702 Mon Sep 17 00:00:00 2001 From: Juraj Vijtiuk Date: Mon, 22 Mar 2021 17:28:06 +0100 Subject: [PATCH] docker: add initial dockerfile and docs Signed-off-by: Juraj Vijtiuk --- README.md | 1 + docker/Dockerfile | 34 ++++++++++++++++++++++++++++++++++ docker/README.md | 20 ++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md diff --git a/README.md b/README.md index f726888a..a29b5dcf 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ These include pthreads and the libnl (https://www.infradead.org/~tgr/libnl/) net This section describes how to build the plugin on hosts that have Sysrepo installed. This includes standard Linux machines and docker images with Sysrepo, Netopeer and other required dependencies. +Additionally, a Dockerfile that builds all the dependencies and the plugin is available in `docker/` First, clone the repo: ``` diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..4cb0ae1d --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,34 @@ +# syntax=docker/dockerfile:1.0.0-experimental +FROM sysrepo/sysrepo-netopeer2:latest + +MAINTAINER juraj.vijtiuk@sartura.hr + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y\ + ssh \ + libnl-3-dev \ + libnl-route-3-dev \ + libnl-nf-3-dev \ + libnl-genl-3-dev + +WORKDIR /opt/dev + +RUN \ + mkdir -m 0600 -p /root/.ssh && ssh-keyscan lab.sartura.hr >> ~/.ssh/known_hosts + +RUN \ + --mount=type=secret,id=sshkey,dst=/root/.ssh/id_ed25519 git clone git@lab.sartura.hr:sysrepo/sysrepo-plugin-interfaces.git + +Run \ + cd sysrepo-plugin-interfaces && mkdir build && cd build && \ + git checkout master && \ + cmake -DCMAKE_BUILD_TYPE="Debug" .. && \ + make -j2 + +RUN \ + sysrepoctl -i /opt/dev/sysrepo-plugin-interfaces/yang/ietf-interfaces@2018-02-20.yang && \ + sysrepoctl -i /opt/dev/sysrepo-plugin-interfaces/yang/iana-if-type@2017-01-19.yang && \ + sysrepoctl -i /opt/dev/sysrepo-plugin-interfaces/yang/ietf-interfaces-common@2019-03-05.yang && \ + sysrepoctl -i /opt/dev/sysrepo-plugin-interfaces/yang/ieee802-dot1q-types.yang && \ + sysrepoctl -i /opt/dev/sysrepo-plugin-interfaces/yang/ietf-if-vlan-encapsulation@2020-07-13.yang diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..7d1f4733 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,20 @@ +# build +As the plugin is currently not open source, we need to clone from a private git server. + +To do that, docker buildkit is required, and a private SSH key +with access to the plugin repo needs to be passed at build time. + +``` +$ export DOCKER_BUILDKIT=1 +$ docker build --progress=plain --secret id=sshkey,src=/home/user/.ssh/id_ed25519 -t sysrepo/interfaces-plugin -f Dockerfile . +``` + +# run +Since the plugin depends on systemd, we need to run the container with `CAP_SYS_ADMIN` privileges and mount the +cgroups FS within the container. + +``` +docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro --cap-add SYS_ADMIN --name interfaces-plugin sysrepo/interfaces-plugin /sbin/init +``` + +