--- /dev/null
+Dockerfile
--- /dev/null
+[Dockerfiles][] for assorted [Gentoo][]-based [Docker][] images.
+
+Dockerfiles are sorted into directories with names matching the
+suggested repository. To avoid duplicating ephemeral data (namespace,
+timestamp tag, …), they appear in the `Dockerfile.template` as markers
+(`NAMESPACE`, `TAG`, …). The `build.sh` script replaces the markers
+with values while generating a `Dockerfile` from each
+`Dockerfile.template`, and then builds each tag with:
+
+ $ docker build -t $NAMESPACE/$REPO:$TAG $REPO
+
+for example:
+
+ $ docker build -t wking/gentoo-en-us:20131205 gentoo-en-us
+
+The dependency graph is:
+
+ wking/gentoo (amd64 stage3)
+ `-- gentoo-portage (adds portage directory)
+ `-- gentoo-en-us (adds locale)
+ `-- gentoo-syslog (adds syslog-ng and associates)
+ `-- buildbot (adds a Buildbot master and slave)
+
+Run:
+
+ $ ./build.sh
+
+to seed from the Gentoo mirrors and build all images. There are a
+number of variables in the `build.sh` script that configure the build
+(`AUTHOR`, `NAMESPACE`, …). We use [POSIX parameter
+expansion][parameter-expansion] to make it easy to override variables
+as you see fit.
+
+ $ NAMESPACE=jdoe DATE=20131210 ./build.sh
+
+I'd like to avoid bloating the images with the Portage tree, but
+without ugly hacks [that is not currently possible][3156] is mounted
+from the host.
+
+[Docker]: http://www.docker.io/
+[Dockerfiles]: http://www.docker.io/learn/dockerfile/
+[Gentoo]: http://www.gentoo.org/
+[parameter-expansion]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
+[3156]: https://github.com/dotcloud/docker/issues/3156
--- /dev/null
+#!/bin/sh
+
+AUTHOR="${AUTHOR:-W. Trevor King <wking@tremily.us>}"
+NAMESPACE="${NAMESPACE:-wking}"
+#PORTAGE="${PORTAGE:-/usr/portage}"
+DATE="${DATE:-20131205}"
+MIRROR="${MIRROR:-http://mirror.mcs.anl.gov/pub/gentoo/}"
+ARCH_URL="${ARCH_URL:-${MIRROR}/releases/amd64/current-stage3/}"
+STAGE3="${STAGE3:-stage3-amd64-${DATE}.tar.bz2}"
+STAGE3_CONTENTS="${STAGE3_CONTENTS:-${STAGE3}.CONTENTS}"
+STAGE3_DIGESTS="${STAGE3_DIGESTS:-${STAGE3}.DIGESTS.asc}"
+
+REPOS="
+ gentoo-portage
+ gentoo-en-us
+ gentoo-syslog
+ buildbot
+ "
+
+function die() {
+ echo "$1"
+ exit 1
+}
+
+STAGE3_IMAGES=$(docker images "${NAMESPACE}/gentoo")
+STAGE3_MATCHES=$(echo "${STAGE3_IMAGES}" | grep "${DATE}")
+if [ -z "${STAGE3_MATCHES}" ]; then
+ # import stage3 image from Gentoo mirrors
+
+ for FILE in "${STAGE3}" "${STAGE3_CONTENTS}" "${STAGE3_DIGESTS}"; do
+ if [ ! -f "downloads/${FILE}" ]; then
+ wget -O "downloads/${FILE}" "${ARCH_URL}/${FILE}"
+ fi
+ done
+
+ gpg --verify "downloads/${STAGE3_DIGESTS}" || die "insecure digests"
+ SHA512_HASHES=$(grep -A1 SHA512 "downloads/${STAGE3_DIGESTS}" | grep -v '^--')
+ SHA512_CHECK=$(cd downloads/ && (echo "${SHA512_HASHES}" | sha512sum -c))
+ SHA512_FAILED=$(echo "${SHA512_CHECK}" | grep FAILED)
+ if [ -n "${SHA512_FAILED}" ]; then
+ die "${SHA512_FAILED}"
+ fi
+
+ docker import - "${NAMESPACE}/gentoo:${DATE}" < "downloads/${STAGE3}" || die "failed to import"
+fi
+
+docker tag -f "${NAMESPACE}/gentoo:${DATE}" "${NAMESPACE}/gentoo:latest" || die "failed to tag"
+
+for REPO in ${REPOS}; do
+ REPO_IMAGES=$(docker images "${NAMESPACE}/${REPO}")
+ REPO_MATCHES=$(echo "${REPO_IMAGES}" | grep "${DATE}")
+ if [ -z "${REPO_MATCHES}" ]; then
+ cp "${REPO}/Dockerfile.template" "${REPO}/Dockerfile"
+ sed -i "s|TAG|${DATE}|g" "${REPO}/Dockerfile"
+ sed -i "s|NAMESPACE|${NAMESPACE}|g" "${REPO}/Dockerfile"
+ sed -i "s|MAINTAINER.*|MAINTAINER ${AUTHOR}|g" "${REPO}/Dockerfile"
+ docker build -t "${NAMESPACE}/${REPO}:${DATE}" "${REPO}" || die "failed to build"
+ fi
+ docker tag -f "${NAMESPACE}/${REPO}:${DATE}" "${NAMESPACE}/${REPO}:latest" || die "failed to tag"
+done
--- /dev/null
+FROM NAMESPACE/gentoo-syslog:TAG
+MAINTAINER A. U. Thor <author@example.com>
+#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+RUN echo 'USE="${USE} sqlite"' >> /etc/portage/make.conf
+RUN echo 'PYTHON_TARGETS="python2_7 python3_3"' >> /etc/portage/make.conf
+RUN echo 'PYTHON_SINGLE_TARGET="python3_3"' >> /etc/portage/make.conf
+RUN echo 'USE_PYTHON="2.7 3.3"' >> /etc/portage/make.conf
+RUN emerge -v1 --newuse dev-lang/python:2.7 dev-lang/python:3.3
+RUN emerge -v dev-util/buildbot dev-util/buildbot-slave
+RUN eselect news read new
+RUN rc-update add buildmaster default
+RUN rc-update add buildslave default
+
+# Container networking happens automatically
+RUN sed -i 's/need net$/use net/' /etc/init.d/*
+
+RUN buildbot create-master /var/lib/buildmaster
+RUN mv /var/lib/buildmaster/master.cfg.sample /var/lib/buildmaster/master.cfg
+RUN buildslave create-slave /var/lib/buildslave localhost:9989 example-slave pass
+RUN chown -R buildbot:buildbot /var/lib/buildmaster /var/lib/buildslave
+
+CMD rc default && tail -F /var/log/messages
+EXPOSE 8010
+EXPOSE 9989
--- /dev/null
+Run this image with:
+
+ $ docker run -d -p 8010:8010 wking/buildbot
+
+it's currently just the default [Buildbot][] config, so there's
+nothing special to configure. Browse to http://localhost:8010/ to see
+the web interface.
+
+[Buildbot]: http://buildbot.net/
--- /dev/null
+FROM NAMESPACE/gentoo-portage:TAG
+MAINTAINER A. U. Thor <author@example.com>
+#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+RUN echo en_US ISO-8859-1 > /etc/locale.gen
+RUN echo en_US.UTF-8 UTF-8 >> /etc/locale.gen
+RUN locale-gen
+RUN echo 'LANG="en_US.UTF-8"' >> /etc/env.d/02locale
+RUN env-update
--- /dev/null
+FROM NAMESPACE/gentoo:TAG
+MAINTAINER A. U. Thor <author@example.com>
+RUN echo 'GENTOO_MIRRORS="http://mirror.mcs.anl.gov/pub/gentoo/"' >> /etc/portage/make.conf
+#RUN echo 'SYNC="rsync://rsync.us.gentoo.org"' >> /etc/portage/make.conf
+RUN mkdir -p /usr/portage
+RUN emerge-webrsync
+RUN emerge --sync --quiet
+RUN eselect news read new
--- /dev/null
+FROM NAMESPACE/gentoo-en-us:TAG
+MAINTAINER A. U. Thor <author@example.com>
+#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+RUN emerge -v sys-process/vixie-cron app-admin/syslog-ng app-admin/logrotate
+RUN rc-update add syslog-ng default
+RUN rc-update add vixie-cron default
+
+# Disable logging to tty12
+RUN sed -i 's/\([^#].*console_all.*\)/#\1/' /etc/syslog-ng/syslog-ng.conf