docker: Switch to official Rust image as base and rework
1. Use the official Rust nightly docker image as base 2. Remove hardcoded user 3. Use named volumes to cache .rustup and .cargo toolchain folders - Changing file permissions to user (chown) only needed on first launch 4. Cleanup apt folders after installing 5. Make bash the default fallback command 6. README.md: Unify workflows for Linux and MacOS
This commit is contained in:
parent
a93a63a6b7
commit
6e3c76ea23
3 changed files with 65 additions and 79 deletions
|
@ -1,47 +1,37 @@
|
|||
FROM ubuntu:17.04
|
||||
FROM rustlang/rust:nightly
|
||||
|
||||
ENV USER user
|
||||
ARG LOCAL_UID=local
|
||||
ARG LOCAL_GID=local
|
||||
ENV BUILD_UID=${LOCAL_UID:-9001}
|
||||
ENV BUILD_GID=${LOCAL_GID:-9001}
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y dirmngr git gosu gcc fuse nasm qemu-utils pkg-config \
|
||||
libfuse-dev make curl wget file sudo apt-transport-https autoconf flex \
|
||||
bison texinfo \
|
||||
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA12E97F0881517F \
|
||||
&& echo "deb https://static.redox-os.org/toolchain/apt/ /" >> /etc/apt/sources.list.d/redox.list \
|
||||
&& apt-get update -o Dir::Etc::sourcelist="redox.list" \
|
||||
&& apt-get install -y x86-64-unknown-redox-newlib x86-64-unknown-redox-binutils x86-64-unknown-redox-gcc \
|
||||
&& if [ $BUILD_UID != local ] && [ $BUILD_GID != local ]; then \
|
||||
groupadd -g $BUILD_GID user; \
|
||||
useradd --shell /bin/bash -u $BUILD_UID -g $BUILD_GID -o -c "" -m $USER; \
|
||||
else \
|
||||
useradd --shell /bin/bash -c "" -m $USER; \
|
||||
fi \
|
||||
&& echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/user-no-sudo-password
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
apt-get install -q -y --no-install-recommends \
|
||||
apt-transport-https \
|
||||
bison \
|
||||
flex \
|
||||
fuse \
|
||||
gosu \
|
||||
libfuse-dev \
|
||||
nasm \
|
||||
qemu-utils \
|
||||
sudo \
|
||||
texinfo \
|
||||
git \
|
||||
; \
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA12E97F0881517F; \
|
||||
echo "deb https://static.redox-os.org/toolchain/apt/ /" >> \
|
||||
/etc/apt/sources.list.d/redox.list; \
|
||||
apt-get update -o Dir::Etc::sourcelist="redox.list"; \
|
||||
apt-get install -q -y --no-install-recommends \
|
||||
x86-64-unknown-redox-newlib \
|
||||
x86-64-unknown-redox-binutils \
|
||||
x86-64-unknown-redox-gcc \
|
||||
; \
|
||||
cargo install xargo; \
|
||||
cargo install cargo-config; \
|
||||
apt-get autoremove -q -y; \
|
||||
apt-get clean -q -y; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
USER $USER
|
||||
ENV HOME /home/$USER
|
||||
ENV PATH $HOME/.cargo/bin:$PATH
|
||||
ENV SRC_PATH $HOME/src
|
||||
WORKDIR $HOME
|
||||
RUN curl https://sh.rustup.rs > sh.rustup.rs \
|
||||
&& sh sh.rustup.rs -y \
|
||||
&& rustup update \
|
||||
&& rustup component add rust-src \
|
||||
&& rustup default nightly \
|
||||
&& curl -O https://ftp.gnu.org/gnu/automake/automake-1.15.1.tar.gz \
|
||||
&& tar -xvpf automake-1.15.1.tar.gz; cd automake-1.15.1; ./configure; make; sudo make install; cd .. \
|
||||
&& cargo install xargo \
|
||||
&& cargo install cargo-config \
|
||||
&& mkdir -p $SRC_PATH
|
||||
|
||||
WORKDIR $SRC_PATH
|
||||
USER root
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
CMD ["/bin/bash"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue