jekyll-theme-isabelline/_blog/jekyll-with-docker.md
2020-09-09 23:10:14 -04:00

2.9 KiB

title layout date tags
Using Jekyll with docker page 2020-09-07 docker docker-compose jekyll

{{ page.title }}

If you have docker desktop installed and you dont wish to install ruby/jekyll, you can use docker to create and author your jekyll-based site.

Getting started

To create a new website, create a new directory:

mkdir new-jekyll-site && cd new-jekyll-site

Run jekyll new in a container:

docker run --rm -it -v (PWD):/srv/jekyll jekyll/jekyll:4 jekyll new .

Configuring isabelline theme

Add the following line to Gemfile:

gem "jekyll-theme-isabelline", "~> 0.1.0"

And add this line to your Jekyll site _config.yaml:

theme: jekyll-theme-isabelline

Chances are if you're creating a site from scratch, Gemfile and _config.yaml will be referencing the theme "minima". Replace with desired theme (in this example jekyll-theme-isabelline).

Run bundle:

docker run --rm -it \
	-v (PWD):/srv/jekyll \
	-v (PWD)/.bundle:/usr/local/bundle \
	-v (PWD)/.gem:/root/.gem \
	jekyll/jekyll:4 bundle

At this point you're ready to run jekyll serve in local mode:

docker run --rm -it -p 4000:4000 \
	-v (PWD):/srv/jekyll \
	-v (PWD)/.bundle:/usr/local/bundle \
	-v (PWD)/.gem:/root/.gem \
	jekyll/jekyll:4 \
	jekyll serve --host 0.0.0.0 --future --draft --force_polling --livereload

Download customized .gitignore, index.html, _config.yaml and docker-compose.yaml

Optionally backup your current files:

mv _config.yml _config.yml.backup
mv _config.yaml _config.yaml.backup
mv index.html index.html.backup
mv .gitignore .gitignore.backup

Download the files:

curl -o _config.yaml https://git.rzen.dev/rzen/jekyll-theme-isabelline/raw/branch/master/_config.yaml
curl -o docker-compose.yaml https://git.rzen.dev/rzen/jekyll-theme-isabelline/raw/branch/master/docker-compose.yaml
curl -o index.html https://git.rzen.dev/rzen/jekyll-theme-isabelline/raw/branch/master/index.html
curl -o private.html https://git.rzen.dev/rzen/jekyll-theme-isabelline/raw/branch/master/private.html
curl -o .gitignore https://git.rzen.dev/rzen/jekyll-theme-isabelline/raw/branch/master/.gitignore

The _config.yaml references several gems that do not come pre-configured on jekyll new, make sure the following gems are declared in Gemfile:

group :jekyll_plugins do
  gem 'jekyll-tidy'
  gem 'jekyll-tagging'
  gem 'jekyll-mentions'
  gem 'jekyll-sitemap'
  gem 'jekyll-feed'
  gem 'jekyll-seo-tag'
end

Create directories for posts, blogs and private notes

mkdir _blog _pages _posts _drafts _private

Docker compose

For your convenience a docker-compose.yaml file is included. Run jekyll serve as follows:

docker-compose up serve

Additionally it can be used to run jekyll, bundle or gem. The service gem-push can be used to publish gems to rubygems.org.