Skip to content

Commit da13d09

Browse files
committed
update Dockerfile: ubuntu 18.04-->20.04, QEMU-5.0-->7.0
1 parent 6b0d8e3 commit da13d09

File tree

1 file changed

+85
-40
lines changed

1 file changed

+85
-40
lines changed

Dockerfile

Lines changed: 85 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,85 @@
1-
FROM ubuntu:18.04
2-
LABEL maintainer="dinghao188" \
3-
version="1.1" \
4-
description="ubuntu 18.04 with tools for tsinghua's rCore-Tutorial-V3"
5-
6-
#install some deps
7-
RUN set -x \
8-
&& apt-get update \
9-
&& apt-get install -y curl wget autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
10-
gawk build-essential bison flex texinfo gperf libtool patchutils bc xz-utils \
11-
zlib1g-dev libexpat-dev pkg-config libglib2.0-dev libpixman-1-dev git tmux python3
12-
13-
#install rust and qemu
14-
RUN set -x; \
15-
RUSTUP='/root/rustup.sh' \
16-
&& cd $HOME \
17-
#install rust
18-
&& curl https://sh.rustup.rs -sSf > $RUSTUP && chmod +x $RUSTUP \
19-
&& $RUSTUP -y --default-toolchain nightly --profile minimal \
20-
21-
#compile qemu
22-
&& wget https://ftp.osuosl.org/pub/blfs/conglomeration/qemu/qemu-5.0.0.tar.xz \
23-
&& tar xvJf qemu-5.0.0.tar.xz \
24-
&& cd qemu-5.0.0 \
25-
&& ./configure --target-list=riscv64-softmmu,riscv64-linux-user \
26-
&& make -j$(nproc) install \
27-
&& cd $HOME && rm -rf qemu-5.0.0 qemu-5.0.0.tar.xz
28-
29-
#for chinese network
30-
RUN set -x; \
31-
APT_CONF='/etc/apt/sources.list'; \
32-
CARGO_CONF='/root/.cargo/config'; \
33-
BASHRC='/root/.bashrc' \
34-
&& echo 'export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static' >> $BASHRC \
35-
&& echo 'export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup' >> $BASHRC \
36-
&& touch $CARGO_CONF \
37-
&& echo '[source.crates-io]' > $CARGO_CONF \
38-
&& echo "replace-with = 'ustc'" >> $CARGO_CONF \
39-
&& echo '[source.ustc]' >> $CARGO_CONF \
40-
&& echo 'registry = "git://mirrors.ustc.edu.cn/crates.io-index"' >> $CARGO_CONF
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
8+
9+
ARG QEMU_VERSION=7.0.0
10+
ARG HOME=/root
11+
12+
# 0. Install general tools
13+
ARG DEBIAN_FRONTEND=noninteractive
14+
RUN apt-get update && \
15+
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}
29+
RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
30+
tar xvJf qemu-${QEMU_VERSION}.tar.xz
31+
32+
# 1.2. Install dependencies
33+
# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites
34+
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
39+
40+
# 1.3. Build and install from source
41+
WORKDIR ${HOME}/qemu-${QEMU_VERSION}
42+
RUN ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \
43+
make -j$(nproc) && \
44+
make install
45+
46+
# 1.4. Clean up
47+
WORKDIR ${HOME}
48+
RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz
49+
50+
# 1.5. Sanity checking
51+
RUN qemu-system-riscv64 --version && \
52+
qemu-riscv64 --version
53+
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
60+
ENV RUSTUP_HOME=/usr/local/rustup \
61+
CARGO_HOME=/usr/local/cargo \
62+
PATH=/usr/local/cargo/bin:$PATH \
63+
RUST_VERSION=nightly
64+
RUN set -eux; \
65+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init; \
66+
chmod +x rustup-init; \
67+
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \
68+
rm rustup-init; \
69+
chmod -R a+w $RUSTUP_HOME $CARGO_HOME;
70+
71+
# 2.2. Sanity checking
72+
RUN rustup --version && \
73+
cargo --version && \
74+
rustc --version
75+
76+
# 3. Build env for labs
77+
# See os1/Makefile `env:` for example.
78+
# This avoids having to wait for these steps each time using a new container.
79+
RUN rustup target add riscv64gc-unknown-none-elf && \
80+
cargo install cargo-binutils --vers ~0.2 && \
81+
rustup component add rust-src && \
82+
rustup component add llvm-tools-preview
83+
84+
# Ready to go
85+
WORKDIR ${HOME}

0 commit comments

Comments
 (0)