From 577b0bf25c4f4c7d0fd6a8f11466a6e126fb15da Mon Sep 17 00:00:00 2001 From: Nemo Date: Thu, 17 May 2018 01:54:54 +0530 Subject: [PATCH] Easier Docker workflow --- .dockerignore | 5 +++++ Dockerfile | 18 +++++++++++------- README.md | 34 ++++++++++++++++++---------------- bootstrap.sh | 14 ++++++++++++-- build_docker.sh | 7 ------- 5 files changed, 46 insertions(+), 32 deletions(-) create mode 100644 .dockerignore delete mode 100755 build_docker.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2ae273e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +html/ +.direnv +*.epub +*.mobi +vendor/ diff --git a/Dockerfile b/Dockerfile index 02f2038..bd61b26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,22 @@ FROM ubuntu:latest -ARG DEBIAN_FRONTEND=noninteractive +ARG DEBIAN_FRONTEND="noninteractive" -RUN apt-get update && apt-get install -y \ +COPY . /src/ + +WORKDIR /src + +RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ calibre \ pandoc \ ruby \ ruby-dev \ wget \ - zlib1g-dev + zlib1g-dev \ + && gem install bundler --no-ri --no-rdoc \ + && bundle install -RUN gem install bundler --no-ri --no-rdoc +ENTRYPOINT ["/src/bootstrap.sh", "docker"] -COPY . / - -RUN bundle install +VOLUME ["/output"] diff --git a/README.md b/README.md index 475914b..8bfac64 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,19 @@ Original sources are downloaded from https://landing.google.com/sre/ # Build +## Docker (Preferred) + +Requirements: + +- Docker + +`docker run --rm --volume "$(pwd):/output" captn3m0/google-sre-ebook:latest` + +- You should see the final EPUB/MOBI files in the `output` directory after the above runs. +- The file may be owned by the root user. + +The build for the above Docker image can be audited at . + ## macOS Review and run the `bootstrap.sh` script to generate the EPUB and MOBI files @@ -15,21 +28,11 @@ Review and run the `bootstrap.sh` script to generate the EPUB and MOBI files Requirements: - Ruby -- gem install bundler -- gem install nokogiri -- brew install pandoc -- brew cask install calibre -- brew install wget - -## Docker - -Requirements: - -- Docker - -``` -$ ./build_docker.sh -``` +- `gem install bundler` +- `gem install nokogiri` +- `brew install pandoc` +- `brew cask install calibre` +- `brew install wget` # Known Issues @@ -37,7 +40,6 @@ $ ./build_docker.sh - metadata.xml is not complete. There are just too many authors - Foreword/Preface is not part of the index - # LICENSE This is licensed under WTFPL. See COPYING file for the full text. diff --git a/bootstrap.sh b/bootstrap.sh index 70ef38c..2e4cfed 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,18 +1,28 @@ #!/bin/bash +# Cleanup rm -rf html mkdir -p html cd html -wget --convert-links --mirror https://landing.google.com/sre/book/ +# Download +wget --convert-links --mirror https://landing.google.com/sre/book/ mv landing.google.com/sre/book/* . rm -rf landing.google.com cd .. -bundle install +if [ $1 != "docker" ];then + bundle install +fi + ruby generate.rb pushd html/chapters pandoc -f html -t epub -o ../../google-sre.epub --epub-metadata=../../metadata.xml --epub-cover-image=../../cover.jpg sre.html popd ebook-convert google-sre.epub google-sre.mobi + +if [ "$1"=="docker" ]; then + chown -v $(id -u):$(id -g) google-sre.* + mv -f google-sre.* /output +fi diff --git a/build_docker.sh b/build_docker.sh deleted file mode 100755 index 8c450e4..0000000 --- a/build_docker.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -docker build -t google-sre-ebook . -docker run -i --rm -v "$(pwd):/output" google-sre-ebook sh -s <