forked from home-assistant/addons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.amd64
241 lines (204 loc) · 7.38 KB
/
Dockerfile.amd64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
ARG BUILD_FROM
ARG BUILD_ARCH
FROM --platform=linux/amd64 debian:bullseye AS cross-builder-base
ENV \
LANG="C.UTF-8" \
DEBIAN_FRONTEND="noninteractive" \
CURL_CA_BUNDLE="/etc/ssl/certs/ca-certificates.crt"
WORKDIR /usr/src
# Allow to reuse downloaded packages (these are only staged build images)
# hadolint ignore=DL3009
RUN \
set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
bash \
curl \
ca-certificates \
build-essential \
git
FROM --platform=linux/amd64 cross-builder-base AS cross-builder-aarch64
COPY debian-arm64.cmake /usr/src/debian.cmake
ENV DEBIAN_ARCH=arm64
ENV DEBIAN_CROSS_PREFIX=aarch64-linux-gnu
ENV SLC_ARCH=linux_arch_64
RUN \
set -x \
&& dpkg --add-architecture arm64 \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
crossbuild-essential-arm64
FROM --platform=linux/amd64 cross-builder-base AS cpcd-builder
ARG CPCD_VERSION
RUN \
set -x \
&& apt-get install -y --no-install-recommends \
cmake \
"libmbedtls-dev" \
"libmbedtls12" \
&& git clone --depth 1 -b "${CPCD_VERSION}" \
https://github.com/SiliconLabs/cpc-daemon.git \
&& mkdir cpc-daemon/build && cd cpc-daemon/build \
&& cmake ../ \
-DENABLE_ENCRYPTION=FALSE \
&& make \
&& make install
FROM --platform=linux/amd64 cross-builder-aarch64 AS cpcd-cross-builder
ARG CPCD_VERSION
RUN \
set -x \
&& apt-get install -y --no-install-recommends \
cmake \
"libmbedtls-dev:${DEBIAN_ARCH}" \
"libmbedtls12:${DEBIAN_ARCH}" \
&& git clone --depth 1 -b "${CPCD_VERSION}" \
https://github.com/SiliconLabs/cpc-daemon.git \
&& mkdir cpc-daemon/build && cd cpc-daemon/build \
&& cmake ../ \
-DCMAKE_TOOLCHAIN_FILE=../debian.cmake \
-DENABLE_ENCRYPTION=FALSE \
&& make \
&& make install
FROM --platform=linux/amd64 cross-builder-aarch64 AS zigbeed-cross-builder
ARG GECKO_SDK_VERSION
RUN \
set -x \
&& apt-get install -y --no-install-recommends \
python3 \
python3-jinja2 \
python3-pip \
openjdk-11-jre \
git-lfs \
unzip \
&& curl -O https://www.silabs.com/documents/login/software/slc_cli_linux.zip \
&& unzip slc_cli_linux.zip \
&& cd slc_cli/ && chmod +x slc
ENV PATH="/usr/src/slc_cli/:$PATH"
RUN \
set -x \
&& git clone --depth 1 -b ${GECKO_SDK_VERSION} \
https://github.com/SiliconLabs/gecko_sdk.git
# zigbeed links against libcpc.so
COPY --from=cpcd-cross-builder /usr/local/ /usr/aarch64-linux-gnu/
COPY 0001-Use-TCP-socket-instead-of-serial-port-SDK.patch /usr/src
COPY 0001-Use-TCP-socket-instead-of-serial-port-main-app.patch /usr/src
COPY execvp-aarch64.patch /usr/src
RUN \
set -x \
&& cd gecko_sdk \
&& patch -p1 < /usr/src/0001-Use-TCP-socket-instead-of-serial-port-SDK.patch \
&& slc signature trust --sdk=. \
&& cd protocol/zigbee \
&& slc generate \
--sdk=../.. \
--with="${SLC_ARCH}" -p=app/zigbeed/zigbeed.slcp \
--export-destination=app/zigbeed/output \
--copy-proj-sources \
&& cd app/zigbeed/output \
&& patch -p1 < /usr/src/0001-Use-TCP-socket-instead-of-serial-port-main-app.patch \
&& patch -p1 < /usr/src/execvp-aarch64.patch \
&& make -f zigbeed.Makefile \
AR="${DEBIAN_CROSS_PREFIX}-ar" \
CC="${DEBIAN_CROSS_PREFIX}-gcc" \
LD="${DEBIAN_CROSS_PREFIX}-gcc" \
CXX="${DEBIAN_CROSS_PREFIX}-g++" \
C_FLAGS="-std=gnu99 -DEMBER_MULTICAST_TABLE_SIZE=16" \
debug
FROM $BUILD_FROM
RUN \
set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
libmbedtls12 \
socat \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /usr/src/*
COPY --from=zigbeed-cross-builder \
/usr/src/gecko_sdk/util/third_party/ot-br-posix /usr/src/ot-br-posix
COPY --from=zigbeed-cross-builder \
/usr/src/gecko_sdk/util/third_party/openthread /usr/src/openthread
COPY --from=cpcd-builder /usr/local/ /usr/local/
ENV BORDER_ROUTING=1
ENV BACKBONE_ROUTER=1
ENV OTBR_OPTIONS "-DOTBR_DBUS=OFF -DOT_MULTIPAN_RCP=ON -DOT_POSIX_CONFIG_RCP_BUS=CPC -DOT_LINK_RAW=1 -DOTBR_VENDOR_NAME=HomeAssistant -DOTBR_PRODUCT_NAME=OpenThreadBorderRouter"
ENV WEB_GUI=1
ENV DOCKER 1
COPY 0001-Avoid-writing-to-system-console.patch /usr/src
COPY 0001-rest-use-correct-Content-Type-header-for-RESTful-API.patch /usr/src
COPY 0002-rest-add-active-dataset-support.patch /usr/src
COPY 0003-rest-add-support-to-set-active-dataset.patch /usr/src
COPY 0004-rest-autostart-Thread-network-when-setting-active-da.patch /usr/src
COPY 0005-web-rest-listen-on-IPv6-addresses-as-well.patch /usr/src
COPY 0006-rest-allow-to-specify-REST-listen-address.patch /usr/src
# Required and installed during build (script/bootstrap), could be removed
ENV OTBR_BUILD_DEPS build-essential ninja-build cmake wget ca-certificates \
libreadline-dev libncurses-dev libcpputest-dev libdbus-1-dev libavahi-common-dev \
libavahi-client-dev libboost-dev libboost-filesystem-dev libboost-system-dev \
libnetfilter-queue-dev
# Build OTBR natively from Gecko SDK sources
WORKDIR /usr/src
RUN \
set -x \
&& apt-get update \
# Install npm/nodejs for WebUI manually to avoid systemd getting pulled in \
&& apt-get install -y --no-install-recommends \
nodejs \
npm \
iproute2 \
patch \
python3 \
python3-dev \
python3-pip \
python3-aiohttp \
python3-cryptography \
python3-yarl \
lsb-release \
sudo \
&& cd ot-br-posix \
&& patch -p1 < /usr/src/0001-rest-use-correct-Content-Type-header-for-RESTful-API.patch \
&& patch -p1 < /usr/src/0002-rest-add-active-dataset-support.patch \
&& patch -p1 < /usr/src/0003-rest-add-support-to-set-active-dataset.patch \
&& patch -p1 < /usr/src/0004-rest-autostart-Thread-network-when-setting-active-da.patch \
&& patch -p1 < /usr/src/0005-web-rest-listen-on-IPv6-addresses-as-well.patch \
&& patch -p1 < /usr/src/0006-rest-allow-to-specify-REST-listen-address.patch \
&& chmod +x ./script/bootstrap \
&& ./script/bootstrap \
&& ln -s ../../../openthread/ third_party/openthread/repo \
&& chmod +x ./script/* \
&& patch -p1 < /usr/src/0001-Avoid-writing-to-system-console.patch \
&& ./script/setup \
&& pip install universal-silabs-flasher==0.0.7 \
&& apt-get purge -y --auto-remove \
build-essential \
patch \
python3-pip \
python3-dev \
git \
git-lfs \
libmbedtls-dev \
${OTBR_BUILD_DEPS} \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /usr/src/*
COPY --from=cpcd-cross-builder /usr/local/lib/* /usr/lib/aarch64-linux-gnu/
RUN \
set -x \
&& dpkg --add-architecture arm64 \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
qemu-user \
libmbedtls12:arm64 \
libstdc++6:arm64 \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /usr/src/*
COPY --from=zigbeed-cross-builder \
/usr/src/gecko_sdk/protocol/zigbee/app/zigbeed/output/build/debug/zigbeed \
/usr/local/bin/zigbeed.aarch64
RUN ldconfig && touch /accept_silabs_msla
COPY rootfs /
COPY rootfs.amd64 /
ENV \
S6_STAGE2_HOOK=/etc/s6-overlay/scripts/otbr-enable-check.sh
HEALTHCHECK --interval=10s --start-period=120s CMD [ "$(s6-svstat -u /run/service/zigbeed)" = "true" ]
# use s6-overlay as init system
WORKDIR /
ENTRYPOINT ["/init"]