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:
+(`${NAMESPACE}`, `${TAG}`, …). The `build.sh` script replaces the
+markers with values while generating a `Dockerfile` from each
+`Dockerfile.template` (using [envsubst][]), and then builds each tag
+with:
$ docker build -t $NAMESPACE/$REPO:$TAG $REPO
[Docker]: http://www.docker.io/
[Dockerfiles]: http://www.docker.io/learn/dockerfile/
[Gentoo]: http://www.gentoo.org/
+[envsubst]: http://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html
[parameter-expansion]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
[3156]: https://github.com/dotcloud/docker/issues/3156
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"
+ env -i \
+ NAMESPACE="${NAMESPACE}" \
+ TAG="${DATE}" \
+ MAINTAINER="${AUTHOR}" \
+ envsubst '
+ ${NAMESPACE}
+ ${TAG}
+ ${MAINTAINER}
+ ' \
+ < "${REPO}/Dockerfile.template" > "${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"
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo-syslog:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/gentoo-syslog:${TAG}
+MAINTAINER ${MAINTAINER}
+#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
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo-java:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/gentoo-java:${TAG}
+MAINTAINER ${MAINTAINER}
+#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"]
RUN echo 'app-misc/elasticsearch ~amd64' >> /etc/portage/package.accept_keywords
RUN emerge -v app-misc/elasticsearch
RUN eselect news read new
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo-portage:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/gentoo-portage:${TAG}
+MAINTAINER ${MAINTAINER}
+#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
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo-syslog:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/gentoo-syslog:${TAG}
+MAINTAINER ${MAINTAINER}
+#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"]
RUN echo 'USE="${USE} -X -cups"' >> /etc/portage/make.conf
RUN emerge -v dev-java/icedtea-bin
RUN eselect news read new
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo:TAG
-MAINTAINER A. U. Thor <author@example.com>
+FROM ${NAMESPACE}/gentoo:${TAG}
+MAINTAINER ${MAINTAINER}
RUN sed -i 's/#rc_sys=""/rc_sys="lxc"/g' /etc/rc.conf
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
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo-en-us:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/gentoo-en-us:${TAG}
+MAINTAINER ${MAINTAINER}
+#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
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/nginx:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/nginx:${TAG}
+MAINTAINER ${MAINTAINER}
+#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"]
RUN wget https://download.elasticsearch.org/kibana/kibana/kibana-3.0.0milestone4.tar.gz
RUN tar -xvf kibana-3.0.0milestone4.tar.gz --strip-components 1 -C /var/www/localhost/htdocs
RUN sed -i 's|"http://"+window.location.hostname+":9200"|"ELASTICSEARCH_URL"|' /var/www/localhost/htdocs/config.js
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo-syslog:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/gentoo-syslog:${TAG}
+MAINTAINER ${MAINTAINER}
+#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"]
RUN emerge -v net-misc/memcached
RUN eselect news read new
RUN rc-update add memcached default
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo-syslog:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/gentoo-syslog:${TAG}
+MAINTAINER ${MAINTAINER}
+#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"]
RUN echo 'NGINX_MODULES_HTTP="access auth_basic autoindex charset fastcgi gzip gzip_static limit_req map proxy rewrite scgi ssi stub_status"' >> /etc/portage/make.conf
RUN echo 'NGINX_MODULES_MAIL=""' >> /etc/portage/make.conf
RUN emerge -v www-servers/nginx
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/portage-import:TAG
-MAINTAINER A. U. Thor <author@example.com>
+FROM ${NAMESPACE}/portage-import:${TAG}
+MAINTAINER ${MAINTAINER}
# -volumes-from doesn't map names, so we need to shift /portage to
# /usr/portage. Add a statically-linked BusyBox for RUN commands.
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo-syslog:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/gentoo-syslog:${TAG}
+MAINTAINER ${MAINTAINER}
+#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"]
RUN emerge -v dev-db/postgresql-server
RUN eselect news read new
RUN rc-update add $(basename /etc/init.d/postgresql-*) default
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo-syslog:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/gentoo-syslog:${TAG}
+MAINTAINER ${MAINTAINER}
+#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"]
RUN emerge -v dev-db/redis
RUN eselect news read new
RUN rc-update add redis default
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-FROM NAMESPACE/gentoo-syslog:TAG
-MAINTAINER A. U. Thor <author@example.com>
-#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+FROM ${NAMESPACE}/gentoo-syslog:${TAG}
+MAINTAINER ${MAINTAINER}
+#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"]
RUN emerge -v net-misc/stunnel
RUN eselect news read new
RUN rc-update add stunnel default