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:
Andre Richter 2017-09-02 21:51:46 +02:00
parent a93a63a6b7
commit 6e3c76ea23
No known key found for this signature in database
GPG key ID: 2116C1AB102F615E
3 changed files with 65 additions and 79 deletions

View file

@ -12,15 +12,10 @@ git clone https://github.com/redox-os/redox.git ; cd redox
```
### Build the container
This will prepare an Ubuntu 17.04 docker image with the required
dependencies and the pre-built toolchain. As long as you rely on this particular
dependencies and toolchain versions, you don't need to rebuild the container.
#### Linux
```shell
docker build --build-arg LOCAL_UID="$(id -u)" --build-arg LOCAL_GID="$(id -g)" \
-t redox docker/
```
#### MacOS
This will prepare a docker image with the required dependencies and
the pre-built toolchain. As long as you rely on this particular
dependencies and toolchain versions, you don't need to rebuild the
container.
```shell
docker build -t redox docker/
```
@ -34,12 +29,12 @@ git pull --rebase --recurse-submodules && git submodule sync \
```
### Run the container to build Redox
#### Linux without security modules
```shell
docker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse \
-e LOCAL_UID="$(id -u)" -e LOCAL_GID="$(id -g)" \
-v redox-"$(id -u)"-"$(id -g)"-cargo:/home/user/.cargo \
-v "$(pwd):/home/user/src" --rm redox make fetch all
-v redox-"$(id -u)-$(id -g)"-cargo:/usr/local/cargo \
-v redox-"$(id -u)-$(id -g)"-rustup:/usr/local/rustup \
-v "$(pwd):$(pwd)" -w "$(pwd)" --rm redox make fetch all
```
#### Linux with security modules<br>
Add the following options depending on the security modules activated on your system:
@ -53,23 +48,13 @@ Ex.: for a SELinux only system such as Fedora or CentOS
docker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse \
-e LOCAL_UID="$(id -u)" -e LOCAL_GID="$(id -g)" \
--security-opt label=disable \
-v redox-"$(id -u)"-"$(id -g)"-cargo:/home/user/.cargo \
-v "$(pwd):/home/user/src" --rm redox make fetch all
```
#### MacOS
```shell
docker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse \
-v redox-cargo:/home/user/.cargo \
-v "$(pwd):/home/user/src" --rm redox make fetch all
-v redox-"$(id -u)-$(id -g)"-cargo:/usr/local/cargo \
-v redox-"$(id -u)-$(id -g)"-rustup:/usr/local/rustup \
-v "$(pwd):$(pwd)" -w "$(pwd)" --rm redox make fetch all
```
### Clear the named volume containing the cargo cache
#### Linux
```shell
docker volume rm redox-"$(id -u)"-"$(id -g)"-cargo
```
#### MacOS
```shell
docker volume rm redox-cargo
docker volume rm redox-"$(id -u)-$(id -g)"-cargo \
redox-"$(id -u)-$(id -g)"-rustup
```