From 3efec95c5b227d5e6eacce184df56ecb0a6bfb98 Mon Sep 17 00:00:00 2001 From: em7 Date: Thu, 15 Feb 2024 21:29:18 +0100 Subject: [PATCH] Added Dockerfile for running Jekyll --- Dockerfile | 17 +++++++++++++++++ README.md | 16 +++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..fc18c341 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM ruby:2.5 + +COPY . /cl-cookbook +WORKDIR /cl-cookbook + +RUN gem install bundler -v 2.1.2 +# This spawns warnings..., let's ignore them using || true trick +RUN bundle install || true + +EXPOSE 4000 + +CMD ["bundle", "exec", "jekyll", "serve", "--host=0.0.0.0", "--incremental"] + +# HOWTO RUN +# docker build -t cl-cookbook . +# docker run -p 4000:4000 -v $(pwd):/cl-cookbook cl-cookbook + diff --git a/README.md b/README.md index c8affb53..7b0aeed1 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,16 @@ You can start by having a look at the [style guide](STYLEGUIDE.md). When adding new content, please ensure it renders properly. -There are two ways to do this: +There are three ways to do this: + +### Install Jekyll system-wide The first option is to install [Jekyll][jekyll] globally and to run `jekyll serve` in a folder where this repository was checked out. Then open `http://127.0.0.1:4000/cl-cookbook/` (the last `/` is important). +### Install system locally using Ruby gems + Another option is to install the Jekyll version of this repository locally with Ruby gems. Since bundler 1.17.3 requires Ruby 2.5 that is rather old, it is recommended to install it using rbenv: 1. Install [rbenv](https://github.com/rbenv/rbenv) using your package manager, or follow [these instructions](https://github.com/rbenv/rbenv#basic-github-checkout) to install it manually. @@ -28,6 +32,16 @@ Another option is to install the Jekyll version of this repository locally with 5. `cd` to the `cl-cookbook` directory and run `bundle install --path vendor/bundle` to install Jekyll locally. 6. Run `bundle exec jekyll serve` to generate the site and host it. +### Use a Docker container + +Since it can be a bit troublesome to install older versions of Ruby onto newer Linux-based systems, another option is to use `docker`. + +1. Build the container by executing `sudo docker build -t cl-cookbook .` in this directory. +2. Run Jekyll inside the container `sudo docker run -p 4000:4000 -v $(pwd):/cl-cookbook cl-cookbook` from this directory. +3. Open your web browser and navigate to `http://127.0.0.1:4000/cl-cookbook/`. + +This command will mount the current working directory into the container and incremental builds are actived so you will be able to see your latest changes without restarting or rebuilding the container. + ### Troubleshooting It can happen that you have older version of ruby installed in the system and