Skip to content

Commit

Permalink
Improve Mbed Docker image used by Build example - Mbed OS workflow (#…
Browse files Browse the repository at this point in the history
…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 <[email protected]>

* Update integrations/docker/images/chip-build/version

Co-authored-by: Justin Wood <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jan 18, 2022
1 parent 24a1be0 commit 90d3d04
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
39 changes: 21 additions & 18 deletions integrations/docker/images/chip-build-mbed-os/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

# ------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion integrations/docker/images/chip-build/version
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 90d3d04

Please sign in to comment.