I haven’t updated my blog for various reasons, one of them is due to my laptop changed including while I was at Cisco and then moved to Palao Alto networks. Jekyll on Ubuntu Jekyll is a very nice framework for blog site. However setting up the development eviroment is not trial while all things are moving include ubuntu OS, ruby version, gem version, jekyll version, plus github, plus I was doing it using a VM running inside VirtualBox. It is not a pleasant expereince every time when I changed my laptop even though I did back up my VM. Mostly it stopped work. This time, I decided to make my bog development into Docker container. To share with others and also remind my self in the future, here are details:

  • Step#1 install docker follow steps here: https://docs.docker.com/engine/install/ubuntu/
  • step#2: docker pull ubuntu:20.04
    svr~$ docker pull ubuntu:20.04
    svr~$ docker images | grep 20.04
    ubuntu                    20.04         e40cf56b4be3   11 days ago         72.8MB
  • step#3: run docker ubuntu
    svr~$ docker run -ti ubuntu:20.04
    root@7446611a9f0a:/# apt update
    ....
    root@7446611a9f0a:/# apt install build-essential zlib1g-dev
  • step#4: install ruby version 2.7.2 thru rvm inside container https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rvm-on-ubuntu-20-04
    root@7446611a9f0a:/# apt update
    root@7446611a9f0a:/# apt install gnupg2
    gpg2 --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
    root@7446611a9f0a:/# \curl -sSL https://get.rvm.io -o rvm.sh
    root@7446611a9f0a:/# cat rvm.sh | bash -s stable --rails
    root@7446611a9f0a:/# source ~/.rvm/scripts/rvm   #should add this into ~/.bashrc
    root@7446611a9f0a:/# rvm install 2.7.2
    root@7446611a9f0a:/# rvm --default use 2.7.2
    Using /usr/local/rvm/gems/ruby-2.7.2
  • step#5: install jekyll
    root@7446611a9f0a:/# gem update --system
    
    root@7446611a9f0a:/# gem install jekyll bundler
  • step#6 find a jekyll theme to use https://jekyllthemes.io/free
    # install git
    root@7446611a9f0a:/# apt install git
    # download a template, I like centrarium
    root@7446611a9f0a:/# cd /root && git clone https://github.com/bencentra/centrarium.git
  • step#7 install required gems for jekyll to run
    root@7446611a9f0a:/# cd /root/centrarium
    root@7446611a9f0a:/# bundle add webrick
    root@7446611a9f0a:/# bundle install
    root@7446611a9f0a:/# bundle exec jekyll server -H 172.17.0.3 # or use any interface IP inside container so that we can test blog by running browser in the host
    ........
     Auto-regeneration: enabled for '/root/centrarium'
        Server address: http://172.17.0.3:4000/
      Server running... press ctrl-c to stop.
    ^Croot@53ca4999c86a:~/centrarium# 
    Make sure the generated blog site is working.
  • step#8 Customize your blog site Clean up all sample dummy posts under "_posts" directory, change "about.mk" etc...
    • Editing _config.yml for your blog site title.
    • Create blog post under "_posts" using markdown
    • Rebuild blog site: bundle exec jekyll server -H 172.17.0.3
    • The site pages are created under directory "_site", which should be copied to deployment site. In my case, I created github repo "weweng.github.io", and upload over there.
    One very important step is to save you docker image from time to time, e.g.
    svr:~$ docker ps
    CONTAINER ID   IMAGE          COMMAND       CREATED             STATUS             PORTS     NAMES
    53ca4999c86a   d8022e61a3e8   "/bin/bash"   About an hour ago   Up About an hour             agitated_hodgkin
    svr:~$ docker commit 53ca4999c86a  u20.4/jekyll
    sha256:3f5b3cd73fb2e654080b902c06e016ac9b23ce0206a8df542849d2b2ed23ae9c
    svr:~$ 
    Next time, when you need to add a new blog post, simply do: "docker tun -ti u20.4/jekyll" this will bring to you back to where it was left last time. When the laptop is to be refreshed, simply save the container image and import. </ul>