|
1 | | -# syntax=docker/dockerfile:1 |
2 | | -# This Dockerfile is adapted from https://github.com/LearningOS/rCore-Tutorial-v3/blob/main/Dockerfile |
3 | | -# with the following major updates: |
4 | | -# - ubuntu 18.04 -> 20.04 |
5 | | -# - qemu 5.0.0 -> 7.0.0 |
6 | | -# - Extensive comments linking to relevant documentation |
7 | | -FROM ubuntu:20.04 |
| 1 | +# Reconstructed Dockerfile from docker history |
| 2 | +# Base image: Ubuntu 22.04 |
| 3 | +FROM ubuntu:22.04 |
8 | 4 |
|
| 5 | +# Build arguments |
| 6 | +ARG RELEASE |
| 7 | +ARG LAUNCHPAD_BUILD_ARCH |
9 | 8 | ARG QEMU_VERSION=7.0.0 |
10 | 9 | ARG HOME=/root |
11 | | - |
12 | | -# 0. Install general tools |
13 | 10 | ARG DEBIAN_FRONTEND=noninteractive |
| 11 | + |
| 12 | +# Install basic tools |
14 | 13 | RUN apt-get update && \ |
15 | 14 | apt-get install -y \ |
16 | | - curl \ |
17 | | - git \ |
18 | | - python3 \ |
19 | | - wget |
20 | | - |
21 | | -# 1. Set up QEMU RISC-V |
22 | | -# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu |
23 | | -# - https://www.qemu.org/download/ |
24 | | -# - https://wiki.qemu.org/Documentation/Platforms/RISCV |
25 | | -# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html |
26 | | - |
27 | | -# 1.1. Download source |
28 | | -WORKDIR ${HOME} |
| 15 | + curl \ |
| 16 | + git \ |
| 17 | + python3 \ |
| 18 | + wget \ |
| 19 | + xz-utils |
| 20 | + |
| 21 | +# Set working directory |
| 22 | +WORKDIR /root |
| 23 | + |
| 24 | +# Download and extract QEMU |
29 | 25 | RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \ |
30 | 26 | tar xvJf qemu-${QEMU_VERSION}.tar.xz |
31 | 27 |
|
32 | | -# 1.2. Install dependencies |
33 | | -# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites |
| 28 | +# Install QEMU build dependencies |
34 | 29 | RUN apt-get install -y \ |
35 | | - autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \ |
36 | | - gawk build-essential bison flex texinfo gperf libtool patchutils bc \ |
37 | | - zlib1g-dev libexpat-dev git \ |
38 | | - ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev |
| 30 | + autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \ |
| 31 | + gawk build-essential bison flex texinfo gperf libtool patchutils bc \ |
| 32 | + zlib1g-dev libexpat-dev git \ |
| 33 | + ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev |
39 | 34 |
|
40 | | -# 1.3. Build and install from source |
41 | | -WORKDIR ${HOME}/qemu-${QEMU_VERSION} |
| 35 | +# Build and install QEMU |
| 36 | +WORKDIR /root/qemu-7.0.0 |
42 | 37 | RUN ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \ |
43 | 38 | make -j$(nproc) && \ |
44 | 39 | make install |
45 | 40 |
|
46 | | -# 1.4. Clean up |
47 | | -WORKDIR ${HOME} |
| 41 | +# Clean up QEMU build files |
| 42 | +WORKDIR /root |
48 | 43 | RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz |
49 | 44 |
|
50 | | -# 1.5. Sanity checking |
| 45 | +# Verify QEMU installation |
51 | 46 | RUN qemu-system-riscv64 --version && \ |
52 | 47 | qemu-riscv64 --version |
53 | 48 |
|
54 | | -# 2. Set up Rust |
55 | | -# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu |
56 | | -# - https://www.rust-lang.org/tools/install |
57 | | -# - https://github.com/rust-lang/docker-rust/blob/master/Dockerfile-debian.template |
58 | | - |
59 | | -# 2.1. Install |
| 49 | +# Set up Rust environment |
60 | 50 | ENV RUSTUP_HOME=/usr/local/rustup \ |
61 | 51 | CARGO_HOME=/usr/local/cargo \ |
62 | | - PATH=/usr/local/cargo/bin:$PATH \ |
| 52 | + PATH=/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ |
63 | 53 | RUST_VERSION=nightly |
| 54 | + |
| 55 | +# Install Rust |
64 | 56 | RUN set -eux; \ |
65 | 57 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init; \ |
66 | 58 | chmod +x rustup-init; \ |
67 | 59 | ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \ |
68 | 60 | rm rustup-init; \ |
69 | 61 | chmod -R a+w $RUSTUP_HOME $CARGO_HOME; |
70 | 62 |
|
71 | | -# 2.2. Sanity checking |
| 63 | +# Verify Rust installation |
72 | 64 | RUN rustup --version && \ |
73 | 65 | cargo --version && \ |
74 | 66 | rustc --version |
75 | 67 |
|
76 | 68 | # 2.3 Env |
77 | 69 | RUN cargo install cargo-binutils; \ |
78 | 70 | rustup target add riscv64gc-unknown-none-elf; \ |
79 | | - rustup component add rust-src; \ |
80 | | - rustup component add llvm-tools-preview; \ |
81 | | - rustup component add rustfmt; \ |
82 | | - rustup component add clippy; |
83 | | - |
84 | | -# 3. Cargo vendor |
85 | | -WORKDIR ${HOME} |
86 | | -COPY os/vendor ./os-vendor |
87 | | -COPY user/vendor ./user-vendor |
88 | | - |
89 | | -# Ready to go |
90 | | -WORKDIR ${HOME} |
| 71 | + rustup component add rust-src; \ |
| 72 | + rustup component add llvm-tools-preview; \ |
| 73 | + rustup component add rustfmt; \ |
| 74 | + rustup component add clippy; |
| 75 | + |
| 76 | + |
| 77 | +# Install Rust components and tools for rCore development |
| 78 | +RUN rustup default $RUST_VERSION; \ |
| 79 | + cargo install cargo-binutils; \ |
| 80 | + rustup target add riscv64gc-unknown-none-elf; \ |
| 81 | + rustup component add rust-src; \ |
| 82 | + rustup component add llvm-tools-preview; \ |
| 83 | + rustup component add rustfmt; \ |
| 84 | + rustup component add clippy; |
| 85 | + |
| 86 | +# Set working directory |
| 87 | +WORKDIR /root |
| 88 | + |
| 89 | +# Default command |
| 90 | +CMD ["/bin/bash"] |
0 commit comments