Use Docker to distribute the build system
Created by: batonius
Problem: Redox's build system is hard to setup and maintain, and changes regularly.
Solution: Use Docker to build self-contained images with all the tools needed and then use them on a local checkout of Redox to build disk images.
Changes introduced by this pull request:
-
Dockerfile
andentrypoint.sh
has been added.
How to use:
- To build an image, run
docker build -t redox .
in thedocker
directory. This will create a new image calledredox
in the local image repository. You can rebuild this image every time you need to update the toolchain. - Instead of
make all
calldocker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse -e LOCAL_USER_ID=`id -u` -v `pwd`:/src --rm redox make all
. To clarify,--cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse
is required to usefuse
inside the container,-e LOCAL_USER_ID=`id -u`
sets theLOCAL_USER_ID
variable to the current uid soentrypoint.sh
can setup a non-root user inside the container to run commands as,-v `pwd`:/src
binds the currend directory as/src
inside the container,--rm
removes the container after it's finished,redox
is the name of the image to run andmake all
is the command to run inside the container. - The container can be run with an interactive shell instead with
docker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse -e LOCAL_USER_ID=`id -u` -v `pwd`:/src --rm -it redox bash
.
How I propose we use it:
- The best way to use it is to setup the official dockerhub repository,
redox-os/toolchain
for example, so a user can skip step 1 above and just calldocker run --cap-add MKNOD --cap-add SYS_ADMIN --device /dev/fuse -e LOCAL_USER_ID=`id -u` -v `pwd`:/src --rm redox-os/toolchain make all
, which would automatically downlad the image and run it as described above. The image will be saved in the local repository until it's updated in the hub. - Dockerhub can be configured to automatically rebuild images from a Dockerfile in a github repository on each push: https://docs.docker.com/docker-hub/builds/ .
- After it's done we can change the Makefile to hide that scary long line behind something like
make all docker=1
. - This setup will allow the maintainer to change the configuration of the build system whenever and however he likes without breaking users's build setups.
TODO:
- I have no idea if it works on *BSD and macOS, options I've used to run
fuse
inside a container might not work.