redox/docker
Andre Richter a93a63a6b7
Docker: Cache cargo downloads with named volume
Currently, cargo downloads dependencies on every single run.
Get rid of this overhead by caching /home/user/.cargo in a
named volume.
2017-08-29 18:08:52 +02:00
..
Dockerfile Docker: allow building the container on MacOS and Linux (#1037) 2017-08-29 11:12:59 +02:00
entrypoint.sh Build docker container with ready to use user env 2017-07-26 00:18:27 +02:00
README.md Docker: Cache cargo downloads with named volume 2017-08-29 18:08:52 +02:00

Building Redox using a Docker image with the pre-built toolchain

All you need is git, make, qemu, fuse and docker. The method requires a non-privileged user able to run the docker command, which is usually achieved by adding the user to the docker group.

It's a four-steps process with variations depending on the platform.

Get the sources

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

docker build --build-arg LOCAL_UID="$(id -u)" --build-arg LOCAL_GID="$(id -g)" \
    -t redox docker/

MacOS

docker build -t redox docker/

Upate the source tree

Note: if you use the container on a different host or with a different user, get the sources first.

git pull --rebase --recurse-submodules && git submodule sync \
    && git submodule update --recursive --init

Run the container to build Redox

Linux without security modules

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

Linux with security modules

Add the following options depending on the security modules activated on your system:

--security-opt label=disable         // disable SELinux
--security-opt seccomp=unconfined    // disable seccomp
--security-opt apparmor=unconfined   // disable AppArmor

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

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

Clear the named volume containing the cargo cache

Linux

docker volume rm redox-"$(id -u)"-"$(id -g)"-cargo

MacOS

docker volume rm redox-cargo