Seven Story Rabbit Hole

Sometimes awesome things happen in deep rabbit holes. Or not.

   images

Setting Up Octopress Under Docker

I got a new computer last week. It’s the latest macbook retina, and I needed to refresh because I wanted a bigger SSD drive (and after having an SSD drive, I’ll never go back)

Anyway, I’m trying to get my Octopress blog going again, and oh my God, what a nightmare. Octopress was working beautifully for me for years, and then all of the sudden I am at the edge of Ruby Dependency Hell staring at an Octopress giving me eight fingers.

With the help of Docker, I’ve managed to tame this eight legged beast, barely.

Run Docker

See Installing Docker for instructions.

This blog post assumes you already have an Octopress git repo. If you are starting from scratch, then check out Octopress Setup Part I to become even more confused.

Install Octopress Docker image

1
$ docker run -ti tleyden5iwx/octopress /bin/bash

After this point, the rest of the instructions assume that you are executing commands from inside the Docker Container.

Delete Octopress dir + clone your Octopress repo

The Docker container will contain an Octopress directory, but it’s not needed.

From within the container:

1
2
3
4
$ cd /root
$ rm -rf octopress/
$ git clone https://github.com/your-github-username/your-github-username.github.io.git octopress
$ cd octopress/

Now, switch to the source branch (which contains the content)

1
$ git checkout source

Re-install dependencies:

1
$ bundle install

Prevent ASCII encoding errors:

1
$ export LC_ALL=C.UTF-8

Clone deploy directory

1
$ git clone https://github.com/your-github-username/your-github-username.github.io.git _deploy

Rake preview

As a smoke test, run:

1
$ bundle exec rake preview

NOTE: I have no idea why bundle exec is required here, I just used this in response to a previous error message and it’s accompanying suggestion.

If this gives no errors, that’s a good sign.

Create a new blog post

1
$ bundle exec rake new_post["Setting up Octopress under Docker"]

It will tell you the path to the blog post. Now open the file in your favorite editor and add contect.

Push to Source branch

The source branch has the source markdown content. It’s actually the most important thing to preserve, because the HTML can always be regnerated from it.

1
$ git push origin source

Deploy to Master branch

The master branch contains the rendered HTML content. Here’s how to push it up to your github pages repo (remember, in an earlier step you cloned your github pages repo at https://github.com/your-github-username/your-github-username.github.io.git)

1
$ bundle exec rake generate && bundle exec rake deploy

After the above command, the changes should be visible on your github pages blog (eg, your-username.github.io)

Common errors

If you get:

1
YAML Exception reading 2014-04-09-a-successful-git-branching-model-with-enterprise-support.markdown: invalid byte sequence in US-ASCII

Run:

1
$ export LC_ALL=C.UTF-8

References

Comments