Skip to content

Commit d0e3471

Browse files
committed
docker: Use openSUSE Leap as a base image for all stages
We had problems with building based on the official Rust image, based on Debian. It's more convenient if we just stick to openSUSE and manage all dependencies ourselves. Signed-off-by: Michal Rostecki <[email protected]>
1 parent 3e92ee7 commit d0e3471

File tree

2 files changed

+39
-37
lines changed

2 files changed

+39
-37
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.gitignore

Dockerfile

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
1-
FROM docker.io/library/rust:latest as builder
2-
RUN wget https://apt.llvm.org/llvm-snapshot.gpg.key && \
3-
apt-key add llvm-snapshot.gpg.key && \
4-
rm -f llvm-snapshot.gpg.key && \
5-
echo "deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-13 main" > /etc/apt/sources.list.d/llvm.list && \
6-
apt update && \
7-
apt upgrade -y --no-install-recommends && \
8-
apt install -y --no-install-recommends \
9-
clang-13 \
10-
libelf-dev \
11-
gcc-multilib \
12-
lld-13 \
13-
lldb-13 \
14-
python3-pip \
15-
sudo && \
16-
apt purge --auto-remove && \
17-
apt clean && \
18-
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
19-
# Build libbpf and bpftool from the newest stable kernel sources.
20-
RUN curl -Lso linux.tar.xz \
21-
$(curl -s https://www.kernel.org/ | grep -A1 "latest_link" | grep -Eo '(http|https)://[^"]+') && \
22-
tar -xf linux.tar.xz && \
23-
cd $(find . -maxdepth 1 -type d -name "linux*") && \
24-
cd tools/lib/bpf && \
25-
make -j $(nproc) && \
26-
make install prefix=/usr && \
27-
cd ../../bpf/bpftool && \
28-
make -j $(nproc) && \
29-
make install prefix=/usr && \
30-
cd ../../../.. && \
31-
rm -rf linux*
32-
RUN cargo install libbpf-cargo
1+
FROM registry.opensuse.org/opensuse/leap:15.3 as builder
2+
RUN zypper ar -p 90 -r https://download.opensuse.org/repositories/devel:/languages:/rust/openSUSE_Leap_15.3/devel:languages:rust.repo \
3+
&& zypper ar -p 90 -r https://download.opensuse.org/repositories/devel:/tools:/compiler/openSUSE_Leap_15.3/devel:tools:compiler.repo \
4+
&& zypper --gpg-auto-import-keys ref \
5+
&& zypper --non-interactive dup --allow-vendor-change
6+
RUN zypper --non-interactive install -t pattern \
7+
devel_C_C++ \
8+
devel_basis \
9+
&& zypper --non-interactive install \
10+
clang \
11+
curl \
12+
libelf-devel \
13+
libopenssl-devel \
14+
llvm \
15+
rustup \
16+
sudo \
17+
tar \
18+
xz \
19+
zlib-devel \
20+
&& zypper clean
21+
RUN rustup-init -y
22+
ENV PATH="/root/.cargo/bin:${PATH}"
3323
RUN rustup component add \
3424
clippy \
3525
rustfmt
26+
RUN cargo install \
27+
libbpf-cargo
3628

3729
FROM builder AS build
30+
WORKDIR /usr/local/src
31+
# Build bpftool from the newest stable kernel sources.
32+
RUN curl -Lso linux.tar.xz \
33+
$(curl -s https://www.kernel.org/ | grep -A1 "latest_link" | grep -Eo '(http|https)://[^"]+') \
34+
&& tar -xf linux.tar.xz \
35+
&& mv $(find . -maxdepth 1 -type d -name "linux*") linux \
36+
&& cd linux \
37+
&& cd tools/bpf/bpftool \
38+
&& make -j $(nproc)
39+
# Prepare lockc sources and build it.
3840
WORKDIR /usr/local/src/lockc
3941
COPY . ./
40-
ENV CLANG /usr/bin/clang-13
4142
RUN cargo build
4243

43-
FROM registry.opensuse.org/opensuse/leap-microdnf:15.3 AS lockcd
44+
FROM registry.opensuse.org/opensuse/leap:15.3 AS lockcd
4445
# runc links those libraries dynamically
45-
RUN microdnf install -y --nodocs \
46+
RUN zypper --non-interactive install \
4647
libseccomp2 \
4748
libselinux1 \
48-
&& microdnf clean all
49-
ARG PROFILE=debug
49+
&& zypper clean
50+
COPY --from=build /usr/local/src/linux/tools/bpf/bpftool/bpftool /usr/sbin/bpftool
5051
COPY --from=build /usr/local/src/lockc/target/$PROFILE/lockcd /usr/bin/lockcd
5152
ENTRYPOINT ["/usr/bin/lockcd"]

0 commit comments

Comments
 (0)