Using Docker to build a Jekyll site with Jenkins14 May 2014
This probably wonʼt be particularly helpful for you. Its probably much easier for you to just run
jekyll build and then deploy however you currently do. I donʼt like to do that though. I prefer to have my site built on git push. That is exactly what I set up here. Its an improvement on my old process of using Jenkins to build my Jekyll site.
- Jenkins up and running
- A Jekyll site in a git repo
- A job in Jenkins to build the site
- The build agent that will build your site needs to have Docker installed
- It also needs to have pull access to the git repo that holds the Jekyll site
- For it to be useful to you, you should have it so that pushing to the git repo will cause a build
Once you have all of that already set up, we start by building the docker container that will be used to generate the site.
One consideration is that you should set the uid of the Jenkins user in the container to the uid of the Jenkins agent. If you do not, youʼll end up with some rather painful permissions issues.
Iʼm sure that you noticed that it has a script to run specified in the Dockerfile. That is up next.
I put both of those files into
_docker so that they wonʼt be included in the site. Commit them to your Jekyll siteʼs repo. Now, we add the build script for in Jenkins
Overall, thats pretty simple. If you didn’t put the Dockerfile and script into the
_docker directory, change the
cd _docker line to match what you chose. You will also need to choose where the built site will end up. I chose to put it in
/var/www/ruin. Feel free to use your user name instead of btobolaski in the script.
This is what I use to build Ruin.io. All I have to do is commit a new post into the git repo and push it. In a few seconds, it appears on the site. It works really great for me but, I’m not sure that any one else will find it very useful.