9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[ReVIEW Tips] DockerでRe:VIEW

Posted at

「ReVIEW」の正式名称が「Re:VIEW」になった記念で、Re:VIEW用DOckerfileを作ってみました。
Re:VIEWと一緒にRuby 2.1.1、TeX Live 2012などがインストールされます(TeX Live 2013のインストール方法はよく分からず…)。

FROM ubuntu:12.04

MAINTAINER takahashim 

RUN apt-get update
RUN apt-get install -y build-essential wget curl git
RUN apt-get install -y zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt-dev
RUN apt-get install -y sqlite3 libsqlite3-dev
RUN apt-get install -y zip unzip
RUN apt-get clean

# Install ruby-build
RUN git clone https://github.com/sstephenson/ruby-build.git .ruby-build
RUN .ruby-build/install.sh
RUN rm -fr .ruby-build

# Install ruby-2.1.1
RUN ruby-build 2.1.1 /usr/local

# Install bundler and rake
RUN gem update --system
RUN gem install bundler --no-rdoc --no-ri

# Install TeXLive
RUN apt-get install -y python-software-properties
RUN apt-get install -y software-properties-common
RUN apt-add-repository ppa:texlive-backports/ppa
RUN apt-get update
RUN apt-get install -y texlive
RUN apt-get install -y texlive-lang-cjk

# Install Re:VIEW
RUN gem install review --no-rdoc --no-ri

# "src" is your Re:VIEW document directory with Rakefile to build
ADD src /review
RUN cd /review && rake

このファイルではRe:VIEWのビルドまで一気に行います(そこまでしなくても良い場合は一番下の3行を消して下さい)。
この場合、Dockerfileがあるディレクトリにsrc/ディレクトリがあって、そこにRakefileも入っている、というディレクトリ構成を想定しています。Rakefileは以下のようなものを作っておきます。

require 'rake/clean'
require 'fileutils'

## Variables

BOOKNAME = "book"
CONFIG_FILE = "config.yml"
OTHER_FILES =  %w{CHAPS PREDEF POSTDEF} << CONFIG_FILE

PDF_FILE = "#{BOOKNAME}.pdf"
EPUB_FILE = "#{BOOKNAME}.epub"

SRC = FileList['*.re'] + OTHER_FILES
CLEAN.include(["#{BOOKNAME}", "#{BOOKNAME}-pdf", "#{BOOKNAME}.pdf", "#{BOOKNAME}-epub", "#{BOOKNAME}.epub"])


## Tasks

##task :default => :pdf
task :default => :all

desc "generate PDF and EPUB file"
task :all => [:pdf, :epub]

desc "generate PDF file"
task :pdf => PDF_FILE

desc "generate EPUB file"
task :epub => EPUB_FILE


## File Tasks

file PDF_FILE => SRC do
  FileUtils.rm_f PDF_FILE
  FileUtils.rm_rf "#{BOOKNAME}-pdf"
  sh "review-pdfmaker #{CONFIG_FILE}"
end

file EPUB_FILE => SRC do
  FileUtils.rm_f EPUB_FILE
  FileUtils.rm_rf "#{BOOKNAME}-epub"
  sh "review-epubmaker #{CONFIG_FILE}"
end

こうすると、Re:VIEWのディレクトリを/reviewに作って、review-pdfmaekrとreview-epubmakerを実行して終わります。

ファイルはDockerのイメージの中に入ったままなので、なんとかして取り出して下さい(docker cpはOS Xだと簡単には使えないようだったので断念…。何かしらサーバでも動かすべき?)。

9
9
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?