1*cfb92d14SAndroid Build Coastguard Worker# Copyright (c) 2022, The OpenThread Authors. 2*cfb92d14SAndroid Build Coastguard Worker# All rights reserved. 3*cfb92d14SAndroid Build Coastguard Worker# 4*cfb92d14SAndroid Build Coastguard Worker# Redistribution and use in source and binary forms, with or without 5*cfb92d14SAndroid Build Coastguard Worker# modification, are permitted provided that the following conditions are met: 6*cfb92d14SAndroid Build Coastguard Worker# 1. Redistributions of source code must retain the above copyright 7*cfb92d14SAndroid Build Coastguard Worker# notice, this list of conditions and the following disclaimer. 8*cfb92d14SAndroid Build Coastguard Worker# 2. Redistributions in binary form must reproduce the above copyright 9*cfb92d14SAndroid Build Coastguard Worker# notice, this list of conditions and the following disclaimer in the 10*cfb92d14SAndroid Build Coastguard Worker# documentation and/or other materials provided with the distribution. 11*cfb92d14SAndroid Build Coastguard Worker# 3. Neither the name of the copyright holder nor the 12*cfb92d14SAndroid Build Coastguard Worker# names of its contributors may be used to endorse or promote products 13*cfb92d14SAndroid Build Coastguard Worker# derived from this software without specific prior written permission. 14*cfb92d14SAndroid Build Coastguard Worker# 15*cfb92d14SAndroid Build Coastguard Worker# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16*cfb92d14SAndroid Build Coastguard Worker# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*cfb92d14SAndroid Build Coastguard Worker# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*cfb92d14SAndroid Build Coastguard Worker# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19*cfb92d14SAndroid Build Coastguard Worker# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20*cfb92d14SAndroid Build Coastguard Worker# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21*cfb92d14SAndroid Build Coastguard Worker# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22*cfb92d14SAndroid Build Coastguard Worker# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23*cfb92d14SAndroid Build Coastguard Worker# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24*cfb92d14SAndroid Build Coastguard Worker# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25*cfb92d14SAndroid Build Coastguard Worker# POSSIBILITY OF SUCH DAMAGE. 26*cfb92d14SAndroid Build Coastguard Worker# 27*cfb92d14SAndroid Build Coastguard Worker 28*cfb92d14SAndroid Build Coastguard WorkerARG BASE_IMAGE=ubuntu:focal 29*cfb92d14SAndroid Build Coastguard WorkerFROM ${BASE_IMAGE} 30*cfb92d14SAndroid Build Coastguard Worker 31*cfb92d14SAndroid Build Coastguard WorkerARG INFRA_IF_NAME 32*cfb92d14SAndroid Build Coastguard WorkerARG BORDER_ROUTING 33*cfb92d14SAndroid Build Coastguard WorkerARG BACKBONE_ROUTER 34*cfb92d14SAndroid Build Coastguard WorkerARG OTBR_OPTIONS 35*cfb92d14SAndroid Build Coastguard WorkerARG EXTERNAL_COMMISSIONER 36*cfb92d14SAndroid Build Coastguard WorkerARG DNS64 37*cfb92d14SAndroid Build Coastguard WorkerARG NAT64 38*cfb92d14SAndroid Build Coastguard WorkerARG NAT64_SERVICE 39*cfb92d14SAndroid Build Coastguard WorkerARG REFERENCE_DEVICE 40*cfb92d14SAndroid Build Coastguard WorkerARG REST_API 41*cfb92d14SAndroid Build Coastguard WorkerARG WEB_GUI 42*cfb92d14SAndroid Build Coastguard WorkerARG MDNS 43*cfb92d14SAndroid Build Coastguard Worker 44*cfb92d14SAndroid Build Coastguard WorkerENV INFRA_IF_NAME=${INFRA_IF_NAME:-eth0} 45*cfb92d14SAndroid Build Coastguard WorkerENV BORDER_ROUTING=${BORDER_ROUTING:-1} 46*cfb92d14SAndroid Build Coastguard WorkerENV BACKBONE_ROUTER=${BACKBONE_ROUTER:-1} 47*cfb92d14SAndroid Build Coastguard WorkerENV OTBR_MDNS=${MDNS:-mDNSResponder} 48*cfb92d14SAndroid Build Coastguard WorkerENV OTBR_OPTIONS=${OTBR_OPTIONS} 49*cfb92d14SAndroid Build Coastguard WorkerENV EXTERNAL_COMMISSIONER=${EXTERNAL_COMMISSIONER:-1} 50*cfb92d14SAndroid Build Coastguard WorkerENV DEBIAN_FRONTEND noninteractive 51*cfb92d14SAndroid Build Coastguard WorkerENV PLATFORM ubuntu 52*cfb92d14SAndroid Build Coastguard WorkerENV REFERENCE_DEVICE=${REFERENCE_DEVICE:-0} 53*cfb92d14SAndroid Build Coastguard WorkerENV NAT64=${NAT64:-1} 54*cfb92d14SAndroid Build Coastguard WorkerENV NAT64_SERVICE=${NAT64_SERVICE:-tayga} 55*cfb92d14SAndroid Build Coastguard WorkerENV DNS64=${DNS64:-0} 56*cfb92d14SAndroid Build Coastguard WorkerENV WEB_GUI=${WEB_GUI:-1} 57*cfb92d14SAndroid Build Coastguard WorkerENV REST_API=${REST_API:-1} 58*cfb92d14SAndroid Build Coastguard WorkerENV DOCKER 1 59*cfb92d14SAndroid Build Coastguard Worker 60*cfb92d14SAndroid Build Coastguard WorkerRUN env 61*cfb92d14SAndroid Build Coastguard Worker 62*cfb92d14SAndroid Build Coastguard WorkerCOPY . /app 63*cfb92d14SAndroid Build Coastguard WorkerWORKDIR /app 64*cfb92d14SAndroid Build Coastguard Worker 65*cfb92d14SAndroid Build Coastguard Worker# Required during build or run 66*cfb92d14SAndroid Build Coastguard WorkerENV OTBR_DOCKER_REQS sudo python2 python3 python-is-python2 67*cfb92d14SAndroid Build Coastguard Worker 68*cfb92d14SAndroid Build Coastguard Worker# Required during build, could be removed 69*cfb92d14SAndroid Build Coastguard WorkerENV OTBR_DOCKER_DEPS git ca-certificates python3-pip wget 70*cfb92d14SAndroid Build Coastguard Worker 71*cfb92d14SAndroid Build Coastguard Worker# Required during run python scripts 72*cfb92d14SAndroid Build Coastguard WorkerENV OTBR_PYTHON_REQS zeroconf 73*cfb92d14SAndroid Build Coastguard Worker 74*cfb92d14SAndroid Build Coastguard Worker# Required and installed during build (script/bootstrap), could be removed 75*cfb92d14SAndroid Build Coastguard WorkerENV OTBR_BUILD_DEPS apt-utils build-essential psmisc ninja-build cmake ca-certificates \ 76*cfb92d14SAndroid Build Coastguard Worker libreadline-dev libncurses-dev libcpputest-dev libdbus-1-dev libavahi-common-dev \ 77*cfb92d14SAndroid Build Coastguard Worker libavahi-client-dev libboost-dev libboost-filesystem-dev libboost-system-dev \ 78*cfb92d14SAndroid Build Coastguard Worker libnetfilter-queue-dev 79*cfb92d14SAndroid Build Coastguard Worker 80*cfb92d14SAndroid Build Coastguard WorkerRUN apt-get update \ 81*cfb92d14SAndroid Build Coastguard Worker && cp -r ./root/. / \ 82*cfb92d14SAndroid Build Coastguard Worker && rm -rf ./root \ 83*cfb92d14SAndroid Build Coastguard Worker && apt-get install --no-install-recommends -y $OTBR_DOCKER_REQS $OTBR_DOCKER_DEPS \ 84*cfb92d14SAndroid Build Coastguard Worker && wget -P /tmp "https://bootstrap.pypa.io/pip/2.7/get-pip.py" \ 85*cfb92d14SAndroid Build Coastguard Worker && python2 /tmp/get-pip.py \ 86*cfb92d14SAndroid Build Coastguard Worker && pip2 install -r /tmp/requirements.txt \ 87*cfb92d14SAndroid Build Coastguard Worker && pip3 install $OTBR_PYTHON_REQS \ 88*cfb92d14SAndroid Build Coastguard Worker && ln -fs /usr/share/zoneinfo/UTC /etc/localtime \ 89*cfb92d14SAndroid Build Coastguard Worker && ([ "${EXTERNAL_COMMISSIONER}" != "1" ] || ( \ 90*cfb92d14SAndroid Build Coastguard Worker git clone https://github.com/openthread/ot-commissioner.git --recurse-submodules --shallow-submodules --depth=1 \ 91*cfb92d14SAndroid Build Coastguard Worker && cd ot-commissioner \ 92*cfb92d14SAndroid Build Coastguard Worker && ./script/bootstrap.sh \ 93*cfb92d14SAndroid Build Coastguard Worker && mkdir -p build \ 94*cfb92d14SAndroid Build Coastguard Worker && cd build \ 95*cfb92d14SAndroid Build Coastguard Worker && cmake -GNinja -DCMAKE_INSTALL_PREFIX="/usr/local" -DOT_COMM_REFERENCE_DEVICE=ON .. \ 96*cfb92d14SAndroid Build Coastguard Worker && ninja \ 97*cfb92d14SAndroid Build Coastguard Worker && ninja install \ 98*cfb92d14SAndroid Build Coastguard Worker && cd /app \ 99*cfb92d14SAndroid Build Coastguard Worker && rm -rf ot-commissioner \ 100*cfb92d14SAndroid Build Coastguard Worker )) \ 101*cfb92d14SAndroid Build Coastguard Worker && ./script/bootstrap \ 102*cfb92d14SAndroid Build Coastguard Worker && ./script/setup \ 103*cfb92d14SAndroid Build Coastguard Worker && ([ "${DNS64}" = "0" ] || chmod 644 /etc/bind/named.conf.options) \ 104*cfb92d14SAndroid Build Coastguard Worker && mv ./script /tmp \ 105*cfb92d14SAndroid Build Coastguard Worker && mv ./etc /tmp \ 106*cfb92d14SAndroid Build Coastguard Worker && find . -delete \ 107*cfb92d14SAndroid Build Coastguard Worker && rm -rf /usr/include \ 108*cfb92d14SAndroid Build Coastguard Worker && mv /tmp/script . \ 109*cfb92d14SAndroid Build Coastguard Worker && mv /tmp/etc . \ 110*cfb92d14SAndroid Build Coastguard Worker && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $OTBR_DOCKER_DEPS \ 111*cfb92d14SAndroid Build Coastguard Worker && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $OTBR_BUILD_DEPS \ 112*cfb92d14SAndroid Build Coastguard Worker && rm -rf /var/lib/apt/lists/* \ 113*cfb92d14SAndroid Build Coastguard Worker && rm -rf /tmp/* \ 114*cfb92d14SAndroid Build Coastguard Worker && sed -i "s/\/root/\/home\/pi/g" /etc/passwd 115*cfb92d14SAndroid Build Coastguard Worker # The command above changes root home directory to /home/pi 116*cfb92d14SAndroid Build Coastguard Worker 117*cfb92d14SAndroid Build Coastguard WorkerENTRYPOINT ["/app/etc/docker/docker_entrypoint.sh"] 118*cfb92d14SAndroid Build Coastguard Worker 119*cfb92d14SAndroid Build Coastguard WorkerEXPOSE 80 120