Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
9
Help us understand the problem. What is going on with this article?
@takahashim

[ReVIEW Tips] DockerでRe:VIEW

More than 5 years have passed since last update.

「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
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
takahashim
Rubyist. Founder and CEO of Tatsu-zine Publishing Inc.

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
9
Help us understand the problem. What is going on with this article?