From 90d3d04e160bf926d2d44a69ac8437d9dba4a70e Mon Sep 17 00:00:00 2001 From: Victor Morales Date: Fri, 22 Oct 2021 19:53:36 -0700 Subject: [PATCH] Improve Mbed Docker image used by Build example - Mbed OS workflow (#10297) * Implement Docker best practices on mbed os image Some of these best practices are: * Multi-stage builds * Pin versions * Avoid additional packages installation * Clean all missing after apt command Signed-off-by: Victor Morales * Update integrations/docker/images/chip-build/version Co-authored-by: Justin Wood --- .../images/chip-build-mbed-os/Dockerfile | 39 ++++++++++--------- integrations/docker/images/chip-build/version | 2 +- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/integrations/docker/images/chip-build-mbed-os/Dockerfile b/integrations/docker/images/chip-build-mbed-os/Dockerfile index cd7724d15ec437..c2f1526fd3833b 100644 --- a/integrations/docker/images/chip-build-mbed-os/Dockerfile +++ b/integrations/docker/images/chip-build-mbed-os/Dockerfile @@ -1,34 +1,37 @@ ARG VERSION=latest -FROM connectedhomeip/chip-build:${VERSION} +FROM connectedhomeip/chip-build:${VERSION} as build -# ------------------------------------------------------------------------------ -# Install system tools via apt RUN set -x \ && apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -fy \ - python3-setuptools \ - python3-usb \ - software-properties-common \ - build-essential \ - astyle \ - mercurial \ - && rm -rf /var/lib/apt/lists \ + && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \ + wget=1.20.3-1ubuntu1 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/ \ && : # last line +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# ------------------------------------------------------------------------------ +# Install openocd +RUN set -x \ + && mkdir -p /opt/openocd \ + && wget -O - --progress=dot:giga https://github.com/cypresssemiconductorco/openocd/releases/download/release-v4.2.0/openocd-4.2.0.1430-linux.tar.gz | tar --strip-components=1 -xz -C /opt/openocd \ + && : # last line + +FROM connectedhomeip/chip-build:${VERSION} + +COPY --from=build /opt/openocd/ /opt/openocd/ + # ------------------------------------------------------------------------------ # Install Python modules RUN set -x \ - && pip3 install --no-cache-dir -U mbed-cli mbed-tools \ + && pip3 install --no-cache-dir -U mbed-cli==1.10.5 mbed-tools==7.44.0 \ && : # last line # ------------------------------------------------------------------------------ -# Install openocd +# Configure mbed build system RUN set -x \ - && (mkdir -p /opt/openocd \ - && cd /opt/openocd \ - && wget --progress=dot:giga https://github.com/cypresssemiconductorco/openocd/releases/download/release-v4.2.0/openocd-4.2.0.1430-linux.tar.gz \ - && tar --strip-components=1 -xzf openocd-4.2.0.1430-linux.tar.gz \ - && rm openocd-4.2.0.1430-linux.tar.gz) \ + && mbed config -G GCC_ARM_PATH /opt/mbed-os-toolchain/gcc-arm-none-eabi-9-2019-q4-major/bin/ \ + && mbed toolchain -G -s GCC_ARM \ && : # last line # ------------------------------------------------------------------------------ diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index 7f2e5259e7066c..a056745373e3f6 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.5.20 Version bump reason: Improve K32W Docker image +0.5.22 Version bump reason: Implement Docker best practices on mbed OS