deis/deis — pull request #1850 by mboersma (2014-09-16 20:53:37+00:00)
Title: ref(cache): optimize Dockerfile for smaller image

Pins our version of Redis to 2.8.15 and builds it from source, discarding the build tools afterward. Based on [docker-library's Redis](https://github.com/docker-library/redis/blob/master/2.8.13/Dockerfile). Reduces the virtual size from 251MB to 144MB. Refs #1825.

Doesn't use deis/base, because it adds several packages that are unused by deis/cache. This strategy of building in one step is an optimization for Dockerfile layers that does add to interactive development time if you modify something in the long compound build recipe. I think cache (and probably router) can benefit from this practice a lot, and that the development burden will not be significant.

Other components such as registry and controller use python and don't have a real "build" step after which tools can be discarded, so this approach may not apply. But i do think untethering from deis/base can shrink each image, and will sidestep the versioning issue we have there.

```console
$ # worst-case build time: no local docker layers
$ time docker build -t deis/cache:optimize .
Sending build context to Docker daemon 44.03 kB
...
Successfully built 7bfddce01450

real	2m4.758s
user	0m0.057s
sys	0m0.051s
$ time docker build -t deis/cache:master .
Sending build context to Docker daemon 43.52 kB
...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise-proposed/restricted/binary-i386/Packages Hash Sum mismatch

E: Some index files failed to download. They have been ignored, or old ones used instead.
2014/09/16 14:41:01 The command [/bin/sh -c apt-get update && apt-get install -yq redis-server] returned a non-zero code: 100

real	2m26.821s
user	0m0.076s
sys	0m0.069s
$ # Oh right, Ubuntu screwed up their mirrors today...
$ docker pull deis/cache:latest
Pulling repository deis/cache
...
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
deis/cache optimize 7bfddce01450 34 minutes ago 143.8 MB
deis/cache latest 14c7798e3b40 4 hours ago 250.9 MB
ubuntu 12.04 c17f3f519388 12 days ago 106.7 MB
deis/base latest 589b5b05090d 5 weeks ago 218.2 MB
```