-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
144 lines (130 loc) · 5.65 KB
/
Dockerfile
File metadata and controls
144 lines (130 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Custom Actions Runner with QEMU and build tools
# Base image: official GitHub Actions runner
FROM ghcr.io/actions/actions-runner:latest
# Switch to root to install packages
USER root
ARG QEMU_VERSION=10.1.2
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC \
PATH=/opt/cargo/bin:/opt/qemu-${QEMU_VERSION}/bin:/opt/x86_64-linux-musl-cross/bin:/opt/aarch64-linux-musl-cross/bin:/opt/riscv64-linux-musl-cross/bin:/opt/loongarch64-linux-musl-cross/bin:${PATH}
# Install common build tools and dependencies
# - build-essential: gcc, g++, make, libc dev headers
# - binfmt-support: helpers for binfmt_misc (host typically manages handlers)
# - Additional dependencies for building QEMU from source
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
git \
ca-certificates \
binfmt-support \
dosfstools \
python3-venv \
udev \
libudev-dev \
openssl \
libssl-dev \
xxd \
wget \
mbpoll \
flex \
bison \
libelf-dev \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
gcc-riscv64-linux-gnu \
g++-riscv64-linux-gnu \
bc \
fakeroot \
coreutils \
cpio \
gzip \
debootstrap \
debian-archive-keyring \
eatmydata \
file \
rsync \
# Additional dependencies for QEMU compilation
libglib2.0-dev \
libfdt-dev \
libpixman-1-dev \
zlib1g-dev \
libnfs-dev \
libiscsi-dev \
python3-dev \
python3-pip \
python3-tomli \
python3-sphinx \
ninja-build \
libslirp0 \
cmake \
clang \
&& rm -rf /var/lib/apt/lists/*
# Build and install QEMU from source
RUN mkdir -p /tmp/qemu-build \
&& cd /tmp/qemu-build \
&& wget "https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz" \
&& tar -xf "qemu-${QEMU_VERSION}.tar.xz" \
&& cd "qemu-${QEMU_VERSION}" \
&& ./configure \
--prefix="/opt/qemu-${QEMU_VERSION}" \
--enable-kvm \
--disable-docs \
--enable-virtfs \
--enable-vhost-net \
--enable-slirp \
&& make -j$(nproc) \
&& make install \
&& cd / \
&& rm -rf /tmp/qemu-build
RUN set -eux; \
for arch in aarch64 riscv64 x86_64 loongarch64; do \
file="${arch}-linux-musl-cross.tgz"; \
if ! wget -q "https://github.com/arceos-org/setup-musl/releases/download/prebuilt/${file}" -O "/tmp/${file}"; then \
if [ "${arch}" = "loongarch64" ]; then \
wget -q "https://github.com/LoongsonLab/oscomp-toolchains-for-oskernel/releases/download/loongarch64-linux-musl-cross-gcc-13.2.0/${file}" -O "/tmp/${file}"; \
else \
wget -q "https://musl.cc/${file}" -O "/tmp/${file}"; \
fi; \
fi; \
tar -xzf "/tmp/${file}" -C /opt; \
rm -f "/tmp/${file}"; \
done
# 串口访问只能是 root 和 dialout 组,这里直把 runner 用户加入 dialout 组
RUN usermod -aG dialout runner
RUN usermod -aG kvm runner
# Return to the default user expected by the runner image
USER runner
# Rust development for runner user
ENV PATH=/home/runner/.cargo/bin:$PATH \
RUST_VERSION=nightly
RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='20a06e644b0d9bd2fbdbfd52d42540bdde820ea7df86e92e533c073da0cdd43c' ;; \
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='3b8daab6cc3135f2cd4b12919559e6adaee73a2fbefb830fadf0405c20231d61' ;; \
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='e3853c5a252fca15252d07cb23a1bdd9377a8c6f3efa01531109281ae47f841c' ;; \
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='a5db2c4b29d23e9b318b955dd0337d6b52e93933608469085c924e0d05b1df1f' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
url="https://static.rust-lang.org/rustup/archive/1.28.2/${rustArch}/rustup-init"; \
wget "$url"; \
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \
rm rustup-init; \
rustup --version; \
cargo --version; \
rustc --version;
# Install additional Rust toolchains, targets and components
RUN rustup toolchain install nightly-2026-04-01 nightly-2026-02-25 && \
rustup target add aarch64-unknown-none-softfloat riscv64gc-unknown-none-elf x86_64-unknown-none loongarch64-unknown-none-softfloat --toolchain nightly-2026-04-01 && \
rustup target add aarch64-unknown-none-softfloat riscv64gc-unknown-none-elf x86_64-unknown-none loongarch64-unknown-none-softfloat --toolchain nightly-2026-02-25 && \
rustup target add aarch64-unknown-none-softfloat riscv64gc-unknown-none-elf x86_64-unknown-none loongarch64-unknown-none-softfloat --toolchain nightly && \
rustup component add clippy llvm-tools rust-src rustfmt --toolchain nightly-2026-04-01 && \
rustup component add clippy llvm-tools rust-src rustfmt --toolchain nightly-2026-02-25 && \
rustup component add clippy llvm-tools rust-src rustfmt --toolchain nightly
# Add Rust mirror configuration to ~/.cargo/config.toml
# RUN echo '[source.crates-io]\nreplace-with = "rsproxy-sparse"\n[source.rsproxy]\nregistry = "https://rsproxy.cn/crates.io-index"\n[source.rsproxy-sparse]\nregistry = "sparse+https://rsproxy.cn/index/"\n[registries.rsproxy]\nindex = "https://rsproxy.cn/crates.io-index"\n[net]\ngit-fetch-with-cli = true' > /home/runner/.cargo/config.toml
RUN cargo install cargo-binutils
RUN cargo install cargo-clone