Joseph Jude

Technology, Psychology, and Story Telling

Write your book using softcover and docker

Posted: Tags: tech,books

Just before starting this blog post, I submitted the final manuscript for my first book. Writing a book is a long and tiring work with uncertain future. Much like a startup.

Writing the book went like this: We, my sister and I, pitched the book to Apress in January, 2016; they vetted the book proposal and approved it; we wrote the book for six months and submitted for review; an editor and a technical reviewer gave their suggestions; we modified and resubmitted; the content of the book is now approved and sent for publishing.

It is still not read by any potential reader. We don't know if the market will accept it or reject it.

I am writing my next book in a different way. I am borrowing the idea of "agile model" from software development practice. Following the agile model, I am writing it in an incremental and iterative model with feedback from potential readers.

Some established publishers like Oreilly already have early release programs. This allows authors to obtain feedback as they progress. I could approach them. But, hyperlinks subverts hierarchy. So, why not try on my own?

I found a platform that supports this mental model. Softcover calls itself a frictionless self-publishing platform. They pay up to 90% royalty. That is not the only reason to love it. Michael Hartl, its founder has worked hard to provide an open business model. He has provided an open source build tool that any author can use to write and generate ebooks. Authors are not even tied to sell using Softcover site. There are no monthly charges. Just a flat 10% fee on a sale through softcover platform. I like this model. So I have chosen it for my next book.

Softcover provides a tool that converts markdown based content into neatly formatted ebooks (mobi, epub, and pdf). It depends on nodejs, ruby, and LaTex so on. Instead of installing all of these on my machine, I chose to use Docker. Docker is best suited for such tools. If you don't know about docker, read this overview post at hackernoon.

Nick Merwin from Softcover has already provided the necessary Dockerfile. It is based on Ubuntu. It works like a charm.

Working with softcover within docker goes like this:

  • Install Docker
  • Save this gist as a Dockerfile in a directory. For reference it is also listed at the end of this post.
  • Build the docker image with docker build -t jjude/sc . (you can tag it as anything. Replace jjude/sc with something of your own)
  • Then go to a directory where you want to create the book. For me it is ~/Dropbox. There issue this command to create a new book: docker run -v .:/book jjude/sc sc new my_new_book. This will create a my_new_book directory with all the required initial content.
  • Follow softcover manual to create the book content. This involves creating content under chapters directory, modifying Book.txt as a ToC, modifying files under config directory, and creating cover images. Use docker run -v .:/book jjude/sc sc server to run the server which will generate html files of the book as you update the files.
  • At any time, you can generate the e-books. Issue docker run -v .:/book jjude/sc sc build:all to build the ebooks. It generates the books in ebooks directory.
  • If you want to publish to softcover, you need to get into the docker container since you need to login to softcover system. Issue docker run -it jjude/sc -v .:/book sh. Now you are into the container. Issue sc login and provide your softcover credentials. Once the login is successful, issue sc publish to publish your ebooks.

For reference the Dockerfile is listed here:

FROM phusion/baseimage:0.9.11
# https://github.com/phusion/baseimage-docker
MAINTAINER Nick Merwin <[email protected]>

ENV HOME /root
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
CMD ["/sbin/my_init"]

RUN apt-get update \
  && apt-get install -y ruby gems g++ ruby-dev libcurl3 libcurl3-gnutls \
  libcurl4-openssl-dev imagemagick default-jre inkscape phantomjs \
  calibre texlive-full nodejs

# nodejs => node
RUN cd /usr/local/bin && ln -s /usr/bin/nodejs node

WORKDIR /root

RUN curl -LO \
  https://github.com/IDPF/epubcheck/releases/download/v3.0/epubcheck-3.0.zip \
  && unzip epubcheck-3.0.zip -d bin && rm epubcheck-3.0.zip

RUN curl -LO \
  http://kindlegen.s3.amazonaws.com/kindlegen_linux_2.6_i386_v2_9.tar.gz \
  && tar -zxvf kindlegen_linux_2.6_i386_v2_9.tar.gz \
  && rm kindlegen_linux_2.6_i386_v2_9.tar.gz \
  && cd /usr/local/bin \
  && ln -s ~/kindlegen kindlegen

RUN apt-get install -y libxslt-dev libxml2-dev build-essential
RUN gem install softcover --pre --no-ri --no-rdoc

RUN softcover check

RUN mkdir /book
WORKDIR /book

EXPOSE 4000

I would like to convert this into an alpine based image. I tried, but I got so many errors. I will have to try it later.

If you are interested, you can follow as I update the book. Check it out at softcover.



Like the post? Retweet it. Got comments? Reply.

Comments

comments powered by Disqus