File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change
1
+ ```
2
+ # Static compile bindings
3
+ WORKDIR /zigbee2mqtt/node_modules/zigbee-herdsman/node_modules/@serialport/bindings
4
+ RUN sed -i "s/'target_name': 'bindings',/&\n 'type': 'static_library',/" binding.gyp && \
5
+ node-gyp clean && \
6
+ node-gyp configure && \
7
+ node-gyp build
8
+ ```
9
+ Results in a nice static /zigbee2mqtt/node_modules/zigbee-herdsman/node_modules/@serialport/bindings /build/Release/bindings.a
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ RUN CORES=$(grep -c '^processor' /proc/cpuinfo); \
35
35
export MAKEFLAGS="-j$((CORES+1)) -l${CORES}" ; \
36
36
npm install --unsafe-perm
37
37
38
+ WORKDIR /zigbee2mqtt
38
39
RUN nexe --build --target alpine --output zigbee2mqtt
39
40
40
41
FROM scratch
@@ -48,11 +49,15 @@ COPY --from=builder /etc_passwd /etc/passwd
48
49
# Serialport is using the udevadm binary
49
50
COPY --from=builder /bin/udevadm /bin/udevadm
50
51
51
- # Copy needed libs for nodejs since it is partially static
52
+ # Copy needed libs(libstdc++.so, libgcc_s.so) for nodejs since it is partially static
53
+ # Copy linker to be able to use them (lib/ld-musl)
54
+ # Can't be fullly static since @serialport uses a C++ node addon
55
+ # https://github.com/serialport/node-serialport/blob/master/packages/bindings/lib/linux.js#L2
52
56
COPY --from=builder \
57
+ /lib/ld-musl-*.so.* \
53
58
/usr/lib/libstdc++.so.* \
54
59
/usr/lib/libgcc_s.so.* \
55
- /usr/ lib/
60
+ /lib/
56
61
57
62
# Copy zigbee2mqtt binary
58
63
COPY --from=builder /zigbee2mqtt/zigbee2mqtt /zigbee2mqtt/zigbee2mqtt
You can’t perform that action at this time.
0 commit comments