[docker] dockerfiles for openthread sim and wpantund (#2760)

This commit is contained in:
Marcin K Szczodrak
2018-06-12 09:18:39 -07:00
committed by Jonathan Hui
parent b4c9f92821
commit 8d21f72cf0
9 changed files with 220 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
VERSION=0.1
all: arm32v7_linux x86_linux sim
arm32v7_linux: arm32v7_ubuntu_wpantund
docker build -t openthread/wpantund_arm32v7_linux arm32v7_ubuntu_wpantund && \
docker push openthread/wpantund_arm32v7_linux && \
docker tag openthread/wpantund_arm32v7_linux openthread/wpantund_arm32v7_linux:$(VERSION) && \
docker push openthread/wpantund_arm32v7_linux:$(VERSION)
x86_linux: x86_ubuntu_wpantund
docker build -t openthread/wpantund_amd64_linux x86_ubuntu_wpantund && \
docker push openthread/wpantund_amd64_linux && \
docker tag openthread/wpantund_amd64_linux openthread/wpantund_amd64_linux:$(VERSION) && \
docker push openthread/wpantund_amd64_linux:$(VERSION)
sim: ot_sim
docker build -t openthread/sim ot_sim && \
docker push openthread/sim && \
docker tag openthread/sim openthread/sim:$(VERSION) && \
docker push openthread/sim:$(VERSION)
publish_manifest:
docker manifest create openthread/wpantund openthread/wpantund_arm32v7_linux openthread/wpantund_amd64_linux
docker manifest annotate openthread/wpantund openthread/wpantund_arm32v7_linux --os linux --arch arm --variant 7
docker manifest annotate openthread/wpantund openthread/wpantund_amd64_linux --os linux --arch amd64
docker manifest push --purge openthread/wpantund
docker manifest create openthread/wpantund:$(VERSION) openthread/wpantund_arm32v7_linux:$(VERSION) openthread/wpantund_amd64_linux:$(VERSION)
docker manifest annotate openthread/wpantund:$(VERSION) openthread/wpantund_arm32v7_linux:$(VERSION) --os linux --arch arm --variant 7
docker manifest annotate openthread/wpantund:$(VERSION) openthread/wpantund_amd64_linux:$(VERSION) --os linux --arch amd64
docker manifest push --purge openthread/wpantund:$(VERSION)
+27
View File
@@ -0,0 +1,27 @@
## Running wpantund from a Docker container:
For a device that has a Thread radio attached to port /dev/ttyUSB0, start wpantund as follows:
```
docker run --rm --detach -e "OPENTHREAD_DEVICE_PORT=/dev/ttyUSB0" --cap-add=NET_ADMIN --device=/dev/ttyUSB0 --name=wpantund openthread/wpantund
```
Once wpantund is running, one can control the Thread interface with wpanctl as follows:
```
docker exec -it wpantund wpanctl
```
## Content
arm32v7_ubuntu_wpantund
- wpantund running on ARMv7 (e.g. Raspberry Pi)
x86_ubuntu_wpantund
- wpantund running on x86
ot_sim
- OpenThread Posix simulator
@@ -0,0 +1,50 @@
# Ubuntu image with tools required to build OpenThread
FROM arm32v7/ubuntu:18.04 as wpantund-dev
LABEL maintainer="Marcin K Szczodrak"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y build-essential git make autoconf autoconf-archive \
automake dbus libtool gcc g++ libreadline-dev libdbus-1-dev libboost-dev
# wpantund
RUN mkdir -p ~/src && \
cd ~/src && \
git clone --recursive https://github.com/openthread/wpantund.git && \
cd wpantund && \
git checkout full/master && \
./configure --sysconfdir=/etc --enable-shared=no && \
make && \
make install
#FROM debian:stretch-slim
FROM arm32v7/ubuntu:18.04
LABEL maintainer="Marcin K Szczodrak"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y libdbus-1-3 libreadline-dev net-tools
RUN mkdir -p /dev/net && \
mknod /dev/net/tun c 10 200 && \
chmod 600 /dev/net/tun
COPY --from=wpantund-dev /usr/local/share/man/man1/wpanctl.1 /usr/local/share/man/man1/wpanctl.1
COPY --from=wpantund-dev /usr/local/share/man/man1/wpantund.1 /usr/local/share/man/man1/wpantund.1
COPY --from=wpantund-dev /usr/local/share/wpantund /usr/local/share/wpantund
COPY --from=wpantund-dev /usr/local/include/wpantund /usr/local/include/wpantund
COPY --from=wpantund-dev /usr/local/bin/wpanctl /usr/local/bin/wpanctl
COPY --from=wpantund-dev /usr/local/sbin/wpantund /usr/local/sbin/wpantund
COPY --from=wpantund-dev /etc/dbus-1/system.d/wpantund.conf /etc/dbus-1/system.d/wpantund.conf
COPY --from=wpantund-dev /etc/wpantund.conf /etc/wpantund.conf
ENTRYPOINT mkdir -p /dev/net && mknod /dev/net/tun c 10 200 && chmod 600 /dev/net/tun && \
service dbus start && \
start-stop-daemon --start --background --quiet --exe /usr/local/sbin/wpantund -- -s $OPENTHREAD_DEVICE_PORT && \
tail -F /dev/null
+19
View File
@@ -0,0 +1,19 @@
FROM alpine:3.6 as openthread-dev
LABEL maintainer="Marcin K Szczodrak"
RUN apk add -U autoconf automake ca-certificates flex git g++ libtool linux-headers make
# openthread
RUN git clone --recursive https://github.com/openthread/openthread.git && \
cd /openthread && \
./bootstrap && \
make -f examples/Makefile-posix
FROM alpine:3.6
LABEL maintainer="Marcin K Szczodrak"
RUN apk add --no-cache libstdc++
COPY --from=openthread-dev /openthread/output/x86_64-unknown-linux-gnu/bin/ot-cli-ftd /bin/ot-cli-ftd
COPY --from=openthread-dev /openthread/output/x86_64-unknown-linux-gnu/bin/ot-cli-mtd /bin/ot-cli-mtd
RUN ln -s /bin/ot-cli-ftd /bin/node
+36
View File
@@ -0,0 +1,36 @@
## Starting simulator
To start the OpenThread simulator, run:
```
docker run --rm -d --name otsim openthread/sim tail -F /dev/null
```
or
```
./start_sim
```
This runs in background a docker container with environment setup to simulate OpenThread nodes.
## Adding a Thread node
To start simulating an OpenThread node #1, run:
```
docker exec -it otsim node 1
```
or
```
./add_node 1
```
This runs a program called node, which is an OpenThread FTD binary, inside the docker container's simulator environment.
## Stopping simulator
To stop the OpenThread simualtor, run:
```
docker stop otsim
```
or
```
./stop_sim
```
This stop the docker daemon process.
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
docker exec -it otsim node $1
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
docker run --rm -d --name otsim openthread/sim tail -F /dev/null
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
docker stop otsim
+50
View File
@@ -0,0 +1,50 @@
# Ubuntu image with tools required to build OpenThread
FROM ubuntu:18.04 as wpantund-dev
LABEL maintainer="Marcin K Szczodrak"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y build-essential git make autoconf autoconf-archive \
automake dbus libtool gcc g++ libreadline-dev libdbus-1-dev libboost-dev
# wpantund
RUN mkdir -p ~/src && \
cd ~/src && \
git clone --recursive https://github.com/openthread/wpantund.git && \
cd wpantund && \
git checkout full/master && \
./configure --sysconfdir=/etc --enable-shared=no && \
make && \
make install
#FROM debian:stretch-slim
FROM ubuntu:18.04
LABEL maintainer="Marcin K Szczodrak"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y libdbus-1-3 libreadline7 net-tools
RUN mkdir -p /dev/net && \
mknod /dev/net/tun c 10 200 && \
chmod 600 /dev/net/tun
COPY --from=wpantund-dev /usr/local/share/man/man1/wpanctl.1 /usr/local/share/man/man1/wpanctl.1
COPY --from=wpantund-dev /usr/local/share/man/man1/wpantund.1 /usr/local/share/man/man1/wpantund.1
COPY --from=wpantund-dev /usr/local/share/wpantund /usr/local/share/wpantund
COPY --from=wpantund-dev /usr/local/include/wpantund /usr/local/include/wpantund
COPY --from=wpantund-dev /usr/local/bin/wpanctl /usr/local/bin/wpanctl
COPY --from=wpantund-dev /usr/local/sbin/wpantund /usr/local/sbin/wpantund
COPY --from=wpantund-dev /etc/dbus-1/system.d/wpantund.conf /etc/dbus-1/system.d/wpantund.conf
COPY --from=wpantund-dev /etc/wpantund.conf /etc/wpantund.conf
ENTRYPOINT mkdir -p /dev/net && mknod /dev/net/tun c 10 200 && chmod 600 /dev/net/tun && \
service dbus start && \
start-stop-daemon --start --background --quiet --exe /usr/local/sbin/wpantund -- -s $OPENTHREAD_DEVICE_PORT && \
tail -F /dev/null