From 9925e661760b27a736f9412884b38d734df1342c Mon Sep 17 00:00:00 2001 From: Christoph Stenglein Date: Sat, 1 Oct 2022 10:51:58 +0200 Subject: [PATCH] dev: reduce docker layers & combine install commands --- Dockerfile | 61 ++++++++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/Dockerfile b/Dockerfile index 766db922a9..5dbe553c6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,44 +54,40 @@ RUN apt-get update && apt-get install -y \ lib32z1 \ libusb-1.0-0-dev \ libudev-dev \ - libhidapi-dev - -RUN apt-get update && apt-get install -y \ + libhidapi-dev \ doxygen \ - graphviz - -# Set gcc-8 as the default gcc -RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100 -RUN update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-8 100 - -# Tools for CI -RUN apt-get update && apt-get install -y \ + graphviz \ + # Tools for CI python \ python3 \ python3-pip \ clang-format-8 \ - clang-tidy-8 + clang-tidy-8 \ + # Developer tools + bash-completion + +# Set gcc-8 as the default gcc +RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100 && \ + update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-8 100 RUN python3 -m pip install --upgrade pip # Python modules COPY py/bitbox02 /tmp/bitbox02 -RUN python3 -m pip install /tmp/bitbox02 -RUN rm -r /tmp/bitbox02 +RUN python3 -m pip install /tmp/bitbox02 && \ + rm -r /tmp/bitbox02 COPY py/requirements.txt /tmp -RUN python3 -m pip install --upgrade --requirement /tmp/requirements.txt -RUN rm /tmp/requirements.txt +RUN python3 -m pip install --upgrade --requirement /tmp/requirements.txt && \ + rm /tmp/requirements.txt -# Python modules for CI RUN python3 -m pip install --upgrade \ + # Python modules for CI pylint==2.13.9 \ pylint-protobuf==0.20.2 \ black==22.3.0 \ mypy==0.960 \ - mypy-protobuf==3.2.0 - -# Python modules for packaging -RUN python3 -m pip install --upgrade \ + mypy-protobuf==3.2.0 \ + # Python modules for packaging setuptools==41.2.0 \ wheel==0.33.6 \ twine==1.15.0 @@ -105,16 +101,13 @@ ENV PATH /opt/protoc/bin:$PATH # Make Python3 the default RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 -# Developer tools -RUN apt-get update && apt-get install -y \ - bash-completion # Install gcovr from PIP to get a newer version than in apt repositories RUN python3 -m pip install gcovr # Install Go, used for the tools in tools/go and for test/gounittest -ENV GOPATH /opt/go -ENV GOROOT /opt/go_dist/go -ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH +ENV GOPATH=/opt/go \ + GOROOT=/opt/go_dist/go \ + PATH=$GOROOT/bin:$GOPATH/bin:$PATH RUN mkdir -p /opt/go_dist && \ curl https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz | tar -xz -C /opt/go_dist @@ -123,15 +116,15 @@ RUN cd /opt && wget https://github.com/linux-test-project/lcov/releases/download ENV PATH /opt/lcov-1.14/bin:$PATH # Install rust compiler -ENV PATH /opt/cargo/bin:$PATH -ENV RUSTUP_HOME=/opt/rustup +ENV PATH=/opt/cargo/bin:$PATH \ + RUSTUP_HOME=/opt/rustup COPY src/rust/rust-toolchain /tmp/rust-toolchain RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | CARGO_HOME=/opt/cargo sh -s -- --default-toolchain $(cat /tmp/rust-toolchain | tr -d '\r\n\t') -y -RUN rustup target add thumbv7em-none-eabi -RUN rustup component add rustfmt -RUN rustup component add clippy -RUN CARGO_HOME=/opt/cargo cargo install cbindgen --version 0.23.0 -RUN CARGO_HOME=/opt/cargo cargo install bindgen --version 0.59.2 +RUN rustup target add thumbv7em-none-eabi && \ + rustup component add rustfmt && \ + rustup component add clippy && \ + CARGO_HOME=/opt/cargo cargo install cbindgen --version 0.23.0 && \ + CARGO_HOME=/opt/cargo cargo install bindgen --version 0.59.2 COPY tools/prost-build prost-build RUN CARGO_HOME=/opt/cargo cargo install --path prost-build --locked