From 985151c3edd25d3ef498da4cb4c94fac7427f204 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 21 May 2021 19:25:40 +0200 Subject: [PATCH] multi-stage build for toolchain installation --- bsp_stm32_freertos/Dockerfile | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/bsp_stm32_freertos/Dockerfile b/bsp_stm32_freertos/Dockerfile index c92cd82..0c81571 100644 --- a/bsp_stm32_freertos/Dockerfile +++ b/bsp_stm32_freertos/Dockerfile @@ -1,21 +1,38 @@ +# Specify the cross compiler version +# See: https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack +ARG XPM_ARM_XCOMPILER_VERSION_DEFAULT="10.2.1-1.1.2" + +# Stage 0 + FROM ubuntu:latest # Issues with XPM cross-compiler on alpine.. # FROM alpine:latest +ARG XPM_ARM_XCOMPILER_VERSION_DEFAULT +ENV XPM_ARM_XCOMPILER_VERSION=$XPM_ARM_XCOMPILER_VERSION_DEFAULT -# Specify the cross compiler version -# See: https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack -ENV XPM_ARM_XCOMPILER_VERSION="10.2.1-1.1.2" - -RUN apt-get update -y && apt-get upgrade -y -RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata -RUN apt-get install -y cmake g++ npm; \ +RUN apt-get update ; \ + DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata; \ + apt-get install -y npm; \ npm install --global xpm@latest; \ xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@${XPM_ARM_XCOMPILER_VERSION} # RUN apk add cmake make bash npm; \ # npm install --global xpm@latest; \ # xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest -ENV PATH="/root/.local/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/${XPM_ARM_XCOMPILER_VERSION}/.content/bin:${PATH}" +# Stage 1 + +FROM ubuntu:latest +# FROM alpine:latest +COPY --from=0 /root/.local/xPacks/@xpack-dev-tools /usr/tools/ +ARG XPM_ARM_XCOMPILER_VERSION_DEFAULT +ENV XPM_ARM_XCOMPILER_VERSION=$XPM_ARM_XCOMPILER_VERSION_DEFAULT +RUN echo ${XPM_ARM_XCOMPILER_VERSION} + +RUN apt-get update && apt-get install -y cmake g++ +# RUN apk add cmake make g++ + +ENV PATH="/usr/tools/arm-none-eabi-gcc/${XPM_ARM_XCOMPILER_VERSION}/.content/bin:${PATH}" + WORKDIR /usr/src/app COPY . .