Skip to content

Instantly share code, notes, and snippets.

@ubermuda
Last active August 29, 2015 14:12
Show Gist options
  • Save ubermuda/7c7ca864e96a3a308c64 to your computer and use it in GitHub Desktop.
Save ubermuda/7c7ca864e96a3a308c64 to your computer and use it in GitHub Desktop.
Build system for the Discovering Docker book

This is the entire source code for the build system of the Discovering Docker book.

It is based on the ubermuda/pandoc-ebook base image:

See http://geoffrey.io/a-base-image-to-build-ebooks.html for more details on this base image.


Here's an overview of my repository's file tree:

.
├── Makefile
└── build
    ├── Dockerfile
    └── build.sh

And it is used like this:

$ make build               # builds the building image
$ make                     # builds the english (default) version of the book
$ LANG=fr make             # builds the french version of the book
#!/bin/bash -x
LANG=${LANG:-en}
COVER=medias/cover.png
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd $DIR/..
SRC="$(pwd)/$LANG"
mkdir -p $SRC/release
rm -f $SRC/release/*
pandoc -S -o $SRC/release/discovering-docker.epub \
--indented-code-classes=code \
--epub-embed-font="Font/roboto-2014/Roboto-Regular.ttf" \
--epub-embed-font="Font/roboto-2014/Roboto-Italic.ttf" \
--epub-embed-font="Font/roboto-2014/Roboto-Bold.ttf" \
--toc --toc-depth=1 \
--epub-cover-image="$SRC/$COVER" \
$SRC/title.txt $SRC/*.md
# stupid kindlegen can't handle a directory in the output path
(cd $SRC/release; /kindle/kindlegen discovering-docker.epub -o discovering-docker.mobi)
pandoc -S -o $SRC/release/discovering-docker.pdf \
--indented-code-classes=code \
--toc --toc-depth=1 \
-V documentclass=book \
$SRC/*.md
(cd $SRC/release; zip ./discovering-docker.zip ./discovering-docker.*)
FROM ubermuda/pandoc-ebook
RUN apt-get install -y zip
CMD ["/bin/bash", "-x", "/book/build/build.sh"]
LANG ?= en
book:
docker run -e LANG=$(LANG) -v $(shell pwd):/book ubermuda/discovering-docker
build:
docker build -t ubermuda/discovering-docker build/
shell:
docker run -w /book -itv $(shell pwd):/book ubermuda/discovering-docker /bin/bash
.PHONY: build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment