1+ FROM rust:1-slim AS builder
2+
3+ ARG PROFILE=release
4+
5+ RUN cat <<'EOF' >/etc/apt/sources.list
6+ deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie main contrib non-free non-free-firmware
7+ # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie main contrib non-free non-free-firmware
8+
9+ deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware
10+ # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware
11+
12+ deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-backports main contrib non-free non-free-firmware
13+ # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-backports main contrib non-free non-free-firmware
14+ deb https://mirrors.tuna.tsinghua.edu.cn/debian-security trixie-security main contrib non-free non-free-firmware
15+ # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security trixie-security main contrib non-free non-free-firmware
16+ EOF
17+
18+ RUN mkdir -p /root/.cargo && cat <<'EOF' >/root/.cargo/config.toml
19+ [source.crates-io]
20+ replace-with = 'rsproxy-sparse'
21+
22+ [source.rsproxy]
23+ registry = "https://rsproxy.cn/crates.io-index"
24+
25+ [source.rsproxy-sparse]
26+ registry = "sparse+https://rsproxy.cn/index/"
27+
28+ [registries.rsproxy]
29+ index = "https://rsproxy.cn/crates.io-index"
30+
31+ [net]
32+ git-fetch-with-cli = true
33+ EOF
34+
35+
36+ WORKDIR /usr/src/rk8s
37+
38+ COPY . .
39+
40+
41+ # install necessary packages
42+ RUN apt-get update && apt-get install --fix-missing -y \
43+ build-essential \
44+ clang \
45+ lld \
46+ pkg-config \
47+ protobuf-compiler \
48+ seccomp \
49+ libseccomp-dev \
50+ libpython3-dev \
51+ openssl \
52+ libssl-dev \
53+ zstd
54+
55+ # start to build
56+ RUN cargo build --release -p rks -p libipam -p libnetwork -p libbridge
57+
58+ # ubuntu:24.04
59+ FROM ubuntu@sha256:7c06e91f61fa88c08cc74f7e1b7c69ae24910d745357e0dfe1d2c0322aaf20f9
60+ ARG ARCH=x86_64
61+
62+
63+ RUN cat <<'EOF' >/etc/apt/sources.list
64+ deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse
65+ # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse
66+ deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse
67+ # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse
68+ deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse
69+ # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse
70+
71+ deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-security main restricted universe multiverse
72+ deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-security main restricted universe multiverse
73+ EOF
74+
75+ RUN apt-get update && \
76+ apt-get install -y --fix-missing --no-install-recommends \
77+ wget \
78+ curl \
79+ iproute2 \
80+ net-tools \
81+ dnsutils \
82+ iputils-ping \
83+ vim \
84+ less \
85+ sudo \
86+ ca-certificates && \
87+ apt-get clean && \
88+ rm -rf /var/lib/apt/lists/*
89+
90+ WORKDIR /root
91+
92+ RUN mkdir -p /etc/net.d
93+
94+ COPY --from=builder /usr/src/rk8s/target/release/libbridge /opt/cni/bin
95+ COPY --from=builder /usr/src/rk8s/target/release/libipam /opt/cni/bin
96+ COPY --from=builder /usr/src/rk8s/target/release/libnetwork /opt/cni/bin
97+ COPY --from=builder /usr/src/rk8s/target/release/rks /usr/bin/rks
98+ COPY --from=builder /usr/src/rk8s/test/test.conflist /etc/net.d
99+ COPY --from=builder /usr/src/rk8s/test/subnet.env /etc/net.d
0 commit comments