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.
This commit is contained in:
Andre Richter 2017-08-29 18:08:52 +02:00
parent 20a38979c4
commit a93a63a6b7
No known key found for this signature in database
GPG key ID: 2116C1AB102F615E

View file

@ -38,6 +38,7 @@ git pull --rebase --recurse-submodules && git submodule sync \
```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
```
#### Linux with security modules<br>
@ -51,11 +52,24 @@ Ex.: for a SELinux only system such as Fedora or CentOS
```shell
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 \
--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
```
### 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
```