|
| 1 | +# Multi-stage build for z03mmc firmware using Debian |
| 2 | +FROM debian:bookworm AS builder |
| 3 | + |
| 4 | +# Prevent interactive prompts |
| 5 | +ENV DEBIAN_FRONTEND=noninteractive |
| 6 | + |
| 7 | +# Install build dependencies |
| 8 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 9 | + cmake \ |
| 10 | + git \ |
| 11 | + gcc \ |
| 12 | + g++ \ |
| 13 | + make \ |
| 14 | + build-essential \ |
| 15 | + binutils \ |
| 16 | + python3 \ |
| 17 | + ca-certificates \ |
| 18 | + && rm -rf /var/lib/apt/lists/* |
| 19 | + |
| 20 | +# Set build environment variables |
| 21 | +ENV BUILD_TYPE=Release \ |
| 22 | + TOOLCHAIN_DIR=/workspace/tc32 \ |
| 23 | + SDK_DIR=/workspace/telink_zigbee_sdk \ |
| 24 | + SDK_PREFIX=/workspace/telink_zigbee_sdk/tl_zigbee_sdk |
| 25 | + |
| 26 | +WORKDIR /workspace |
| 27 | + |
| 28 | +# Clone the tc32 toolchain |
| 29 | +RUN git clone https://github.com/devbis/tc32.git -b linux --depth 1 ${TOOLCHAIN_DIR} |
| 30 | + |
| 31 | +# Clone the Telink Zigbee SDK |
| 32 | +RUN git clone https://github.com/telink-semi/telink_zigbee_sdk.git -b V3.7.1.0 --depth 1 ${SDK_DIR} |
| 33 | + |
| 34 | +# Copy project source |
| 35 | +COPY . /workspace/project/ |
| 36 | + |
| 37 | +WORKDIR /workspace/project |
| 38 | + |
| 39 | +# Build the firmware |
| 40 | +RUN cmake -B /workspace/build \ |
| 41 | + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ |
| 42 | + -DSDK_PREFIX=${SDK_PREFIX} \ |
| 43 | + -DTOOLCHAIN_PREFIX=${TOOLCHAIN_DIR} && \ |
| 44 | + cmake --build /workspace/build --config ${BUILD_TYPE} --target=z03mmc.zigbee |
| 45 | + |
| 46 | +# Export stage - for direct artifact extraction |
| 47 | +FROM scratch AS export |
| 48 | + |
| 49 | +ARG BUILD_TYPE=Release |
| 50 | + |
| 51 | +# Copy firmware artifacts (only the key binaries) |
| 52 | +COPY --from=builder /workspace/build/src/z03mmc.bin /${BUILD_TYPE}/z03mmc.bin |
| 53 | +COPY --from=builder /workspace/build/src/*.zigbee /${BUILD_TYPE}/ |
| 54 | +COPY --from=builder /workspace/build/src/z03mmc /${BUILD_TYPE}/z03mmc |
| 55 | + |
| 56 | +# Final stage - minimal runtime image (optional, for docker run) |
| 57 | +FROM debian:bookworm-slim |
| 58 | + |
| 59 | +ARG BUILD_TYPE=Release |
| 60 | + |
| 61 | +WORKDIR /output |
| 62 | + |
| 63 | +COPY --from=builder /workspace/build/src/ ./${BUILD_TYPE}/ |
| 64 | + |
| 65 | +CMD ["/bin/sh"] |
0 commit comments