Updated 2015-08-30: Dokku has changed its stack to include herokuish instead of buildstep. This makes things better as will be coming very soon in a new blog post.
As it turns out, I had keeping my dokku apps up to date completely wrong. The containers that your dokku apps run in are not based on the ubuntu:trusty
Docker image. They're instead based on ubuntu-debootstrap:14.04
. Additionally, currently you can't trust the progrium/cedarish
and progrium/buildstep
images from Docker Hub, as they're not updated when the base image is updated (Issues are filed on cedarish and buildstep to make this rebuilding automatic on Docker Hub).
However, you can tell your host machine to rebuild the images itself. The script I'm now running daily to keep all the dokku things up to date is below:
#!/bin/bash | |
# before you can use this, you need to run (as root): | |
# git clone https://github.com/progrium/buildstep.git /root/buildstep | |
# git clone https://github.com/progrium/cedarish.git /root/cedarish | |
# First, we need to get our base ubuntu images up to date | |
docker pull ubuntu-debootstrap:14.04 | |
docker pull ubuntu:trusty # for postgresql | |
# First update all our dokku plugins from their origins | |
pushd /var/lib/dokku/plugins | |
for d in *; | |
do | |
pushd $f | |
if git status -s; then | |
git pull | |
fi | |
popd $f | |
done | |
# And force them all to rebuild! | |
dokku plugins-install | |
# Next, rebuild the cedarish stack | |
pushd /root/cedarish | |
git pull origin | |
docker build -t progrium/cedarish:cedar14 cedar14 # build a new cedarish stack | |
popd | |
# Next, rebuild the buildstep | |
pushd /root/buildstep | |
git pull origin # pull down the latest buildstep code | |
make build # build it! | |
popd | |
# Rebuild all our apps on the new base image | |
dokku ps:rebuildall | |
sleep 120 # Sleep to allow old processes to exit | |
# Now clean up old containers and old images | |
docker ps -a --no-trunc | grep 'Exit' | awk '{print $1}' | xargs -L 1 -r docker rm | |
docker rmi $(docker images -f "dangling=true" -q) |
- Lines 8 and 9 pull the latest Ubuntu images from Docker Hub.
- Lines 11-23 update all the dokku plugins I have. This is an optional step, especially to be avoided if you need to vet every change to your environment.
- Lines 26-29 rebuild the cedarish image. Note that this will only do a build if the base image is also new. Docker is good about this.
- Lines 32-25 do the same thing for the buildstep image.
- Line 38 rebuilds and redeploys all of our apps.
- Line 39 waits for 2 minutes, so that the old containers can die peacefully.
- Lines 42 and 43 clean up old containers and images. There's some good discussion on Docker container cleanup methods, I picked what I liked.
TODO:
- Detect if either
cedarish
orbuildstep
actually changed in their rebuilds, and exit before line 38 if they did.