|
| 1 | +# RIP and Docker |
| 2 | + |
| 3 | +How to use Docker to manage building and testing RIP. |
| 4 | + |
| 5 | +## Installing Docker |
| 6 | + |
| 7 | +You need to be using a Linux system in order to use Docker, on Ubuntu |
| 8 | + |
| 9 | +If you're on Ubuntu there are docker packages available in the multiverse, but the CE version from [the official website](https://docs.docker.com/install/linux/docker-ce/ubuntu/) will perform much better and offers newer features. |
| 10 | + |
| 11 | +On MacOS, docker is available and will automatically run a Linux VM for you. On windows, you *can't* use the subsystem, since Docker depends on Linux kernel namespaces. |
| 12 | + |
| 13 | +Once installed, be sure to do whatever group management to your account so that you can run docker without the need of sudo. (For CE, this is something like `adduser $USER docker` and then rebooting.) |
| 14 | + |
| 15 | +## The Dependency Dockerfile |
| 16 | + |
| 17 | +Right now there are two dockerfiles, one that builds the dependencies (onto an Ubuntu base), and one that copies the source code of RIP. |
| 18 | + |
| 19 | +The dependency image is sourced from `external/Dockerfile` and is built automatically by dockerhub, as `utkrobotics/rip_deps`. |
| 20 | + |
| 21 | +To pull the latest deps image: |
| 22 | + |
| 23 | +```docker pull utkrobotics/rip_deps``` |
| 24 | + |
| 25 | +This includes g2o, eigen, suitesparse, etc, whatever is needed to build. |
| 26 | + |
| 27 | +## The building / interactive Dockerfile |
| 28 | + |
| 29 | +This is the Dockerfile in the root of the repo. |
| 30 | + |
| 31 | +It's based off the `rip_deps` image so it will have everything needed to build already installed. |
| 32 | + |
| 33 | +Upon building this container image, it will copy all the source code from your current directory into the container and set up an environment ready to run the build. |
| 34 | + |
| 35 | +To build the interactive container: |
| 36 | + |
| 37 | +``` |
| 38 | +docker build --tag utkrobotics/rip:$(git symbolic-ref HEAD|cut -d'/' -f3-|sed -e 's;/;_;') . |
| 39 | +``` |
| 40 | + |
| 41 | +This will create an image `utkrobotics/rip:yourbranch` which we can then run and create an instance of: |
| 42 | + |
| 43 | +``` |
| 44 | +# --rm : removes the container when you exit it |
| 45 | +# -t -i : creates an interactive container |
| 46 | +# zsh -l : the command to run inside the container (use whatever your preferred shell is) |
| 47 | +docker run --rm -t -i utkrobotics/rip:$(git symbolic-ref HEAD|cut -d'/' -f3-|sed -e 's;/;_;') zsh -l |
| 48 | +``` |
| 49 | + |
| 50 | +Now that you're inside the container, you can immediately build it, mess around, do whatever, because everything you do inside the container is removed when you exit it, and it never affects the code outside the container. |
| 51 | + |
| 52 | +Normally, what I do is: |
| 53 | + |
| 54 | +``` |
| 55 | +# build dat stuff |
| 56 | +./build-linux.sh |
| 57 | +# runs the built unit tests |
| 58 | +./travis/script.sh |
| 59 | +``` |
| 60 | + |
| 61 | +While you're in the container, feel free to do whatever you want, `rm -rf *`, or anything. Just remember if you make changes that you want to keep inside the container, you should make those same changes again outside the container on your local git repo. |
| 62 | + |
| 63 | +If you've made changed to your local git repo, you should run the build command again to update the image with your new changes. |
0 commit comments