xref: /DragonOS/tools/Dockerfile (revision 7c958c9ef0cd25eb15abb21d0d3420aac1c67c88)
1FROM debian:bullseye
2
3# 设置工作目录
4WORKDIR /build-image
5
6# 将本地的脚本复制到工作目录
7COPY *.sh ./
8
9# 设置用来存放rust缓存的卷
10VOLUME [ "/root/.cargo/registry" ]
11
12# 设置rust源的环境变量
13ENV RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
14ENV RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
15
16RUN sed -i "s@http://\(deb\|security\).debian.org@http://mirrors.ustc.edu.cn@g" /etc/apt/sources.list && apt update && apt install -y \
17    ca-certificates \
18    curl \
19    gnupg \
20    lsb-release \
21    llvm-dev libclang-dev clang gcc-multilib \
22    gcc build-essential fdisk dosfstools qemu-kvm \
23    sudo wget
24
25# 安装Rust
26RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y && \
27    # You have to add the rustup variables to the $PATH
28    echo "export PATH=\"\$HOME/.cargo/bin:\$PATH\"" >> ~/.bashrc && \
29    bash -c "source $HOME/.cargo/env && \
30    # 更换cargo的索引源
31    touch $HOME/.cargo/config && \
32    bash change_rust_src.sh && \
33    # 安装rust的编译工具
34    echo "正在安装DragonOS所需的rust组件...首次安装需要一些时间来更新索引,请耐心等待..." && \
35    cargo install cargo-binutils && \
36    rustup toolchain install nightly && \
37    rustup default nightly && \
38    rustup component add rust-src && \
39    rustup component add llvm-tools-preview && \
40    rustup target add x86_64-unknown-none"
41
42# 编译安装GCC交叉编译工具链
43RUN bash build_gcc_toolchain.sh -f
44
45# 清除缓存
46WORKDIR /
47RUN apt-get autoremove -q -y && \
48    apt-get clean -q -y && \
49    rm -rf /build-image
50
51ENV DragonOS_GCC=/root/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin/
52# 设置容器启动后执行的命令
53CMD ["/bin/bash"]
54