Write Go Interactively, Export Directly to a Docker Image

February 21, 2016 0 Comments

Note - There is a new version of gophernotes! Please follow the instructions here to install gophernotes and use Go in Jupyter/nteract. Unfortunately the containerize command has been deprecated, but maybe it will return at some point.

I attended Jupyter Day Chicago today, and had a blast! What a great community of developers and data scientists with some exciting ideas about interactive data exploration, collaborative coding, and more. Keep an eye on the Jupyter Project, because there are some really great things coming (see here for more hype). Better yet, jump in and contribute!

In addition to the talks, Jupyter Day also included some hacking sessions. I pitched an idea to further develop the recent gophernotes Golang kernel for Jupyter (see here for more info, and here for example notebooks). Specifically, I pitched an idea to implement one-click building of docker images straight from within a Jupyter notebook, and, guess what, ... we did it! (well at least for Golang notebooks).

Now you can interactively code Golang in a Jupyter Notebook via gophernotes and, assuming you have docker installed locally, you can build a Go binary and Docker image that runs that binary straight from the notebook with the :containerize command:

Did you catch that? Here is what just happened:

  1. You programmed something cool (well really just a log here, but imagine something cool) interactively in the browser in a Golang notebook.

  2. You decide that you like the process you coded and you want it to be portable, deployable, testable in some environment, etc., so you decide to dockerize it.

  3. You type :containerize.

  4. You are done... that easy.

Thanks to my team of hackers for helping me with this, finding some gophernotes bugs, and improving documentation. Specifically, thanks to Bobby Norton, Vicente Cano, and Josh Cheek for pull requests, comments, and valuable input.