• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2#  Copyright (c) 2020, The OpenThread Authors.
3#  All rights reserved.
4#
5#  Redistribution and use in source and binary forms, with or without
6#  modification, are permitted provided that the following conditions are met:
7#  1. Redistributions of source code must retain the above copyright
8#     notice, this list of conditions and the following disclaimer.
9#  2. Redistributions in binary form must reproduce the above copyright
10#     notice, this list of conditions and the following disclaimer in the
11#     documentation and/or other materials provided with the distribution.
12#  3. Neither the name of the copyright holder nor the
13#     names of its contributors may be used to endorse or promote products
14#     derived from this software without specific prior written permission.
15#
16#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26#  POSSIBILITY OF SUCH DAMAGE.
27#
28
29name: Docker
30
31on:
32  push:
33    branches-ignore:
34      - 'dependabot/**'
35  pull_request:
36    branches:
37      - 'main'
38
39concurrency:
40  group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/ot-br-posix' && github.run_id) || github.ref }}
41  cancel-in-progress: true
42
43jobs:
44
45  docker-check:
46    runs-on: ubuntu-latest
47    env:
48      OTBR_COVERAGE: 1
49      VERBOSE: 1
50    steps:
51    - uses: actions/checkout@v4
52      with:
53        submodules: true
54    - name: Bootstrap
55      env:
56        BUILD_TARGET: "docker-check"
57      run: tests/scripts/bootstrap.sh
58    - name: Check
59      run: tests/scripts/check-docker
60
61  buildx:
62    runs-on: ubuntu-24.04
63    strategy:
64      fail-fast: false
65      matrix:
66        include:
67          - image_tag: "latest"
68            base_image: "ubuntu:bionic"
69            build_args: ""
70            platforms: "linux/amd64,linux/arm/v7,linux/arm64"
71            push: yes
72          - image_tag: "focal"
73            base_image: "ubuntu:focal"
74            build_args: ""
75            platforms: "linux/amd64,linux/arm64"
76            push: yes
77          - image_tag: "reference-device"
78            base_image: "ubuntu:bionic"
79            build_args: >-
80              --build-arg REFERENCE_DEVICE=1
81              --build-arg BORDER_ROUTING=0
82              --build-arg BACKBONE_ROUTER=1
83              --build-arg NAT64=0
84              --build-arg WEB_GUI=0
85              --build-arg REST_API=0
86              --build-arg OTBR_OPTIONS='-DOTBR_DUA_ROUTING=ON -DOT_DUA=ON -DOT_MLR=ON'
87            platforms: "linux/amd64,linux/arm/v7,linux/arm64"
88            push: yes
89          - image_tag: "test"
90            base_image: "ubuntu:bionic"
91            build_args: >-
92              --build-arg OT_BACKBONE_CI=1
93              --build-arg REFERENCE_DEVICE=1
94              --build-arg BACKBONE_ROUTER=1
95              --build-arg OTBR_OPTIONS='-DOTBR_DUA_ROUTING=ON -DOT_DUA=ON -DOT_MLR=ON'
96            platforms: "linux/amd64,linux/arm/v7,linux/arm64"
97            push: no
98    steps:
99    - uses: actions/checkout@v4
100      with:
101        submodules: true
102
103    - name: Prepare
104      id: prepare
105      run: |
106        DOCKER_IMAGE=openthread/otbr
107        DOCKER_PLATFORMS=${{ matrix.platforms }}
108        VERSION=${{ matrix.image_tag }}
109
110        TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
111
112        echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
113        echo "version=${VERSION}" >> $GITHUB_OUTPUT
114        echo "buildx_args=--platform ${DOCKER_PLATFORMS} \
115          --build-arg BASE_IMAGE=${{ matrix.base_image }} \
116          --build-arg VERSION=${VERSION} \
117          --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
118          --build-arg VCS_REF=${GITHUB_SHA::8} \
119          ${{ matrix.build_args }} \
120          ${TAGS} --file etc/docker/Dockerfile ." >> $GITHUB_OUTPUT
121
122    - name: Set up QEMU
123      uses: docker/setup-qemu-action@v3
124      with:
125        image: tonistiigi/binfmt:qemu-v8.1.5
126
127    - name: Set up Docker Buildx
128      uses: docker/setup-buildx-action@v3
129
130    - name: Docker Buildx (build)
131      run: |
132        docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
133
134    - name: Login to DockerHub
135      if: success() && github.repository == 'openthread/ot-br-posix' && github.event_name != 'pull_request' && matrix.push
136      uses: docker/login-action@v3
137      with:
138        username: ${{ secrets.DOCKER_USERNAME }}
139        password: ${{ secrets.DOCKER_PASSWORD }}
140
141    - name: Docker Buildx (push)
142      if: success() && github.repository == 'openthread/ot-br-posix' && github.event_name != 'pull_request' && matrix.push
143      run: |
144        docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
145
146    - name: Inspect Image
147      if: always() && github.repository == 'openthread/ot-br-posix' && github.event_name != 'pull_request' && matrix.push
148      run: |
149        docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
150