Skip to content

Commit

Permalink
docker: add initial dockerfile and docs
Browse files Browse the repository at this point in the history
Signed-off-by: Juraj Vijtiuk <[email protected]>
  • Loading branch information
jvijtiuk committed Mar 22, 2021
1 parent cd2d39b commit d0abdd4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand Down
34 changes: 34 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# syntax=docker/dockerfile:1.0.0-experimental
FROM sysrepo/sysrepo-netopeer2:latest

MAINTAINER [email protected]

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 [email protected]: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/[email protected] && \
sysrepoctl -i /opt/dev/sysrepo-plugin-interfaces/yang/[email protected] && \
sysrepoctl -i /opt/dev/sysrepo-plugin-interfaces/yang/[email protected] && \
sysrepoctl -i /opt/dev/sysrepo-plugin-interfaces/yang/ieee802-dot1q-types.yang && \
sysrepoctl -i /opt/dev/sysrepo-plugin-interfaces/yang/[email protected]
20 changes: 20 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -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
```


0 comments on commit d0abdd4

Please sign in to comment.