-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
52 lines (43 loc) · 1.65 KB
/
Dockerfile
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
FROM ubuntu:bionic
MAINTAINER Jonir Rings
# shared data
VOLUME ["/data"]
# change the mirror to USTC (only for china mainland)
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN apt-get update --fix-missing
# general dependencies
RUN apt-get install -y curl git
# install target toolchain
RUN apt-get install -y gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
RUN apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
# set root .profile for shell
WORKDIR /root
ENV USER root
RUN echo 'export PATH="$HOME/.cargo/bin:$PATH"' > /root/.profile
# change the rust mirror to USTC (only for china mainland)
RUN echo 'export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static' >> /root/.profile
RUN echo 'export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup' >> /root/.profile
# change runtime mirrot to USTC (only for china mainland)
ENV RUSTUP_DIST_SERVER https://mirrors.ustc.edu.cn/rust-static
ENV RUSTUP_UPDATE_ROOT https://mirrors.ustc.edu.cn/rust-static/rustup
# install Rust
RUN curl https://sh.rustup.rs -sSf > rustup.sh
RUN chmod +x rustup.sh
RUN /bin/sh -c './rustup.sh -y'
# install cross-compiled targets
RUN /root/.cargo/bin/rustup target add armv7-unknown-linux-gnueabihf aarch64-unknown-linux-gnu
# configure cargo for cross compilation
COPY ./configure.sh /root/configure.sh
RUN chmod +x /root/configure.sh
RUN /root/configure.sh
# generate hello world
WORKDIR /root
ENV USER root
ENV PATH $PATH:/root/.cargo/bin
RUN cargo new hello
# build
WORKDIR /root/hello
RUN cargo build --target=armv7-unknown-linux-gnueabihf
RUN cargo build --target=aarch64-unknown-linux-gnu
WORKDIR /root
CMD ["bash"]