First lets install jekyll:

gem install jekyll

Then let’s create our site:

jekyll init site

And cd into the site:

cd site

Add the following Dockerfile:

FROM ruby:2.3-alpine AS jekyll-builder
ENV RAILS_ENV production

RUN apk update && apk --update add ruby ruby-irb nodejs ruby-json ruby-rake \
   ruby-bigdecimal ruby-io-console libstdc++ tzdata  \
   libffi-dev libxml2-dev libxslt-dev

# Necessary for some gems which are compiled on bundle install

RUN apk add --virtual build-deps git build-base ruby-dev \
   libc-dev linux-headers && \
   gem install bundler --no-ri --no-rdoc && \
   bundle config build.nokogiri --use-system-libraries

COPY Gemfile* /app/
RUN bundle install --clean --without development test
COPY . /app
RUN bundle exec jekyll build -d ./build --verbose

# Copy to our nginx

FROM nginx:alpine
COPY --from=jekyll-builder /app/build /usr/share/nginx/html

And then finally build your site:

docker build -t site

Happy dockering

Hey you 👋 Want FREE resources to become the best developer and get a competitive edge? Subscribe!

Would you like to stay up to date on ? Subscribe here! I'll only use your email to keep u up to date on new technology and software development tips. It wont be shared. Feel free to unsubscribe anytime!