So - why not?

I recently replaced my Macbook Air with a shiny Surface Pro 4. There’s lots of downsides of doing such a thing - but also lots of ups.

The form factor is awesome. Touch Screens are great and properly made displays are great. I think Apple have some catching up to do. But…

Suddenly I can’t do some things I’m used to doing. I need to fix that… part 1 is being able to post a blog entry from Windows. Now this sounds like it should be really simple. It’s not.

My blog runs on an older version of Octopress - lots of reasons for this and I don’t have the time to spend changing to something else. I actually like the workflow and I shouldn’t have to change it just because I changed OS.

To do this I needed the Windows Insider Preview. Worth noting you don’t need that to do the bit where I deploy the change to Google Cloud.

Bash for Windows and Octopress

This turned out to be a bit of a pain. Bash for Windows sets its umask to 0777 - thanks Windows! Bundler does not appreciate this. Also Bash for Windows is an Ubuntu 14.04 run time - and I’ll be needing Ruby versions.

1
2
3
4
5
6
7
8
9
10
$ sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
$ cd
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ exec $SHELL
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
$ exec $SHELL
$ rbenv install 2.2.1

With that sorted I can now do the harder bit:

1
2
3
$ umask u=rwx,g=rx,o=rx  # This changes it for this session only
$ cd /mnt/c/Users/leepa/Documents/octopress
$ bundle install --path=~/octopress/vendor/gems

Wait - why am I specifying the –path here? Okay, first, it’s just sensible to keep the deps somewhere else other than the main gem population. Secondly and this bit is more important The /mnt/c/ is all 0777 perms and bundler will correctly not appreciate that.

Once this is done I can go ahead and do my normal post creation.

Right, with that done I need to deploy this!

Docker Public Beta and Google Cloud SDK

This is a match made in heaven. First of all I enabled Hyper-V and installed the latest Docker Beta for Windows (which uses Hyper-V instead of VirtualBox). I then go ahead and install the Google SDK and the kubectl command using the commands provided in my previous post.

Snag: You need to have HOME set. Set it to your /Users/foo folder where foo is your username. It’s the default directory when you open a new command prompt so that shouldn’t be too difficult.

If you don’t set it the gcloud get credentials command will tell you that it needs to be set.

Now with all the done:

Bash:

1
$ bundle exec rake generate

Windows:

1
2
3
4
$ docker build gcr.io/PROJECT_ID/leepaio-blog:v3 .
$ gcloud docker push gcr.io/PROJECT_ID/leepaio-blog:v3
$ kubectl edit deployment
... edit the relevant container line, save and exit

That’s it! Wrote a blog post on a blog generator that doesn’t work on Windows using the Container Engine from Google that doesn’t support Windows - all without leaving Windows.

Mission accomplished!