14
14
# limitations under the License.
15
15
16
16
# Latest Ubuntu LTS
17
- FROM ubuntu:22.04
18
- ENV DEBIAN_FRONTEND noninteractive
17
+ FROM ubuntu:22.04@sha256:0eb0f877e1c869a300c442c41120e778db7161419244ee5cbc6fa5f134e74736
18
+ ENV DEBIAN_FRONTEND= noninteractive
19
19
20
- RUN apt-get update && apt-get upgrade -y && apt-get install -y wget nano rsync curl gnupg2 jq unzip bzip2
20
+ RUN apt-get update && apt-get upgrade -y &&\
21
+ apt-get install -y wget nano rsync curl gnupg2 jq unzip bzip2 &&\
22
+ rm -r /var/lib/apt/lists/*
21
23
22
- # for clang-*-15, see https://apt.llvm.org/
24
+ # Install gcc8-arm-none-eabi
25
+ RUN wget -O gcc.tar.bz2 https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2018q4/gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2?revision=d830f9dd-cd4f-406d-8672-cca9210dd220?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,8-2018-q4-major &&\
26
+ echo "fb31fbdfe08406ece43eef5df623c0b2deb8b53e405e2c878300f7a1f303ee52 gcc.tar.bz2" | sha256sum -c &&\
27
+ tar -xjf gcc.tar.bz2 -C /usr/local --strip-components=1 &&\
28
+ rm -f gcc.tar.bz2
29
+
30
+ # for clang-*-18, see https://apt.llvm.org/
23
31
RUN echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \
24
32
echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \
25
33
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
26
34
27
- # Install gcc8-arm-none-eabi
28
- RUN mkdir ~/Downloads &&\
29
- cd ~/Downloads &&\
30
- wget -O gcc.tar.bz2 https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2018q4/gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2?revision=d830f9dd-cd4f-406d-8672-cca9210dd220?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,8-2018-q4-major &&\
31
- echo "fb31fbdfe08406ece43eef5df623c0b2deb8b53e405e2c878300f7a1f303ee52 gcc.tar.bz2" | sha256sum -c &&\
32
- cd ~/Downloads &&\
33
- tar -xjvf gcc.tar.bz2 &&\
34
- rm -f gcc.tar.bz2 &&\
35
- cd ~/Downloads && rsync -a gcc-arm-none-eabi-8-2018-q4-major/ /usr/local/
36
-
37
- # Tools for building
38
35
RUN apt-get update && apt-get install -y \
39
- build-essential \
36
+ make \
40
37
llvm-18 \
41
38
gcc-10 \
42
39
binutils \
@@ -54,95 +51,81 @@ RUN apt-get update && apt-get install -y \
54
51
lib32z1 \
55
52
libusb-1.0-0-dev \
56
53
libudev-dev \
57
- libhidapi-dev
58
-
59
- RUN apt-get update && apt-get install -y \
54
+ libhidapi-dev \
60
55
doxygen \
61
- graphviz
56
+ graphviz \
57
+ python3 \
58
+ python3-pip \
59
+ clang-format-18 \
60
+ clang-tidy-18 \
61
+ bash-completion \
62
+ && rm -r /var/lib/apt/lists/*
62
63
63
64
# Set gcc-10 as the default gcc
64
65
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
65
66
RUN update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-10 100
66
67
67
- # Tools for CI
68
- RUN apt-get update && apt-get install -y \
69
- python3 \
70
- python3-pip \
71
- clang-format-18 \
72
- clang-tidy-18
68
+ # Make Python3 the default
69
+ RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
73
70
74
- RUN python3 -m pip install --upgrade pip
71
+ # Install latest pip
72
+ RUN python -m pip install --no-cache-dir --upgrade pip==24.2
75
73
76
74
# Python modules
77
- COPY py/bitbox02 /tmp/bitbox02
78
- RUN python3 -m pip install /tmp/bitbox02
79
- RUN rm -r /tmp/bitbox02
80
- COPY py/requirements.txt /tmp
81
- RUN python3 -m pip install --upgrade --requirement /tmp/requirements.txt
82
- RUN rm /tmp/requirements.txt
75
+ RUN --mount=source=py/bitbox02,target=/mnt/bitbox02,rw \
76
+ pip install --no-cache-dir /mnt/bitbox02
77
+ RUN --mount=source=py/requirements.txt,target=/mnt/requirements.txt \
78
+ pip install --no-cache-dir --upgrade --requirement /mnt/requirements.txt
83
79
84
80
# Python modules for CI
85
- RUN python3 -m pip install --upgrade \
81
+ RUN pip install --no-cache-dir --upgrade \
86
82
pylint==2.13.9 \
87
83
pylint-protobuf==0.20.2 \
88
84
black==22.3.0 \
89
85
mypy==0.960 \
90
- mypy-protobuf==3.2.0
91
-
92
- # Python modules for packaging
93
- RUN python3 -m pip install --upgrade \
86
+ mypy-protobuf==3.2.0 \
94
87
setuptools==41.2.0 \
95
88
wheel==0.33.6 \
96
- twine==1.15.0
89
+ twine==1.15.0 \
90
+ gcovr==7.2
97
91
98
92
# Install protoc from release, because the version available on the repo is too old
99
93
RUN mkdir -p /opt/protoc && \
100
94
curl -L0 https://github.com/protocolbuffers/protobuf/releases/download/v21.2/protoc-21.2-linux-x86_64.zip -o /tmp/protoc-21.2-linux-x86_64.zip && \
101
- unzip /tmp/protoc-21.2-linux-x86_64.zip -d /opt/protoc
102
- ENV PATH /opt/protoc/bin:$PATH
103
-
104
- # Make Python3 the default
105
- RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
106
-
107
- # Developer tools
108
- RUN apt-get update && apt-get install -y \
109
- bash-completion
110
- # Install gcovr from PIP to get a newer version than in apt repositories
111
- RUN python3 -m pip install gcovr
95
+ unzip /tmp/protoc-21.2-linux-x86_64.zip -d /opt/protoc &&\
96
+ rm /tmp/protoc-21.2-linux-x86_64.zip
97
+ ENV PATH=/opt/protoc/bin:$PATH
112
98
113
99
# Install Go, used for the tools in tools/go and for test/gounittest
114
- ENV GOPATH /opt/go
115
- ENV GOROOT /opt/go_dist/go
116
- ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH
100
+ ENV GOPATH= /opt/go
101
+ ENV GOROOT= /opt/go_dist/go
102
+ ENV PATH= $GOROOT/bin:$GOPATH/bin:$PATH
117
103
RUN mkdir -p /opt/go_dist && \
118
104
curl https://dl.google.com/go/go1.19.3.linux-amd64.tar.gz | tar -xz -C /opt/go_dist
119
105
120
106
# Install lcov from release (the one from the repos is too old).
121
- RUN cd /opt && wget https://github.com/linux-test-project/lcov/releases/download/v1.14/lcov-1.14.tar.gz && tar -xf lcov-1.14.tar.gz
122
- ENV PATH /opt/lcov-1.14/bin:$PATH
107
+ RUN curl -L https://github.com/linux-test-project/lcov/releases/download/v1.14/lcov-1.14.tar.gz | tar -xz -C /opt
108
+ ENV PATH= /opt/lcov-1.14/bin:$PATH
123
109
124
110
# Install rust compiler
125
- ENV PATH /opt/cargo/bin:$PATH
111
+ ENV PATH= /opt/cargo/bin:$PATH
126
112
ENV RUSTUP_HOME=/opt/rustup
127
- COPY src/rust/rust-toolchain.toml /tmp/rust-toolchain.toml
128
- RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | CARGO_HOME=/opt/cargo sh -s -- --default-toolchain $(grep -oP '(?<=channel = ")[^"]+' /tmp/rust-toolchain.toml) -y
129
- RUN rustup target add thumbv7em-none-eabi
130
- RUN rustup component add rustfmt
131
- RUN rustup component add clippy
132
- RUN rustup component add rust-src
133
- RUN CARGO_HOME=/opt/cargo cargo install cbindgen --version 0.26.0 --locked
134
- RUN CARGO_HOME=/opt/cargo cargo install bindgen-cli --version 0.69.4 --locked
113
+ RUN --mount=source=tools/prost-build-proto,target=/mnt/prost-build-proto,rw \
114
+ --mount=source=src/rust/rust-toolchain.toml,target=/mnt/rust-toolchain.toml \
115
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |\
116
+ CARGO_HOME=/opt/cargo sh -s -- --default-toolchain $(grep -oP '(?<=channel = ")[^"]+' /mnt/rust-toolchain.toml) -y &&\
117
+ rustup target add thumbv7em-none-eabi &&\
118
+ rustup component add rustfmt &&\
119
+ rustup component add clippy &&\
120
+ rustup component add rust-src &&\
121
+ CARGO_HOME=/opt/cargo cargo install cbindgen --version 0.26.0 --locked &&\
122
+ CARGO_HOME=/opt/cargo cargo install bindgen-cli --version 0.69.4 --locked &&\
123
+ CARGO_HOME=/opt/cargo cargo install --path /mnt/prost-build-proto --locked
135
124
136
125
# Until cargo vendor supports vendoring dependencies of the rust std libs we
137
126
# need a copy of this file next to the toml file. It also has to be world
138
127
# writable so that invocations of `cargo vendor` can update it. Below is the
139
128
# tracking issue for `cargo vendor` to support rust std libs.
140
129
# https://github.com/rust-lang/wg-cargo-std-aware/issues/23
141
- RUN cp "$(rustc --print=sysroot)/lib/rustlib/src/rust/Cargo.lock" "$(rustc --print=sysroot)/lib/rustlib/src/rust/library/test/"
142
- RUN chmod 777 $(rustc --print=sysroot)/lib/rustlib/src/rust/library/test/Cargo.lock
143
-
144
- COPY tools/prost-build-proto prost-build-proto
145
- RUN CARGO_HOME=/opt/cargo cargo install --path prost-build-proto --locked
146
-
147
- # Clean temporary files to reduce image size
148
- RUN rm -rf /var/lib/apt/lists/*
130
+ RUN cp "$(rustc --print=sysroot)/lib/rustlib/src/rust/Cargo.lock" "$(rustc --print=sysroot)/lib/rustlib/src/rust/library/test/" &&\
131
+ chmod 777 $(rustc --print=sysroot)/lib/rustlib/src/rust/library/test/Cargo.lock
0 commit comments