diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..52e1939 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM ruby:3.0.0 as jekyll + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + git \ + && rm -rf /var/lib/apt/lists/* + +# used in the jekyll-server image, which is FROM this image +COPY docker-entrypoint.sh /usr/local/bin/ + +RUN gem update --system && gem install jekyll && gem cleanup + +EXPOSE 4000 + +WORKDIR /site + +ENTRYPOINT [ "jekyll" ] + +CMD [ "--help" ] + +# build from the image we just built with different metadata +FROM jekyll as jekyll-serve + +COPY --from=jekyll /usr/local/bin/docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh + +# on every container start, check if Gemfile exists and warn if it's missing +ENTRYPOINT [ "docker-entrypoint.sh" ] + +CMD [ "bundle", "exec", "jekyll", "serve", "--force_polling", "-H", "0.0.0.0", "-P", "4000" ] \ No newline at end of file diff --git a/Gemfile b/Gemfile index 19a2b61..8b33d06 100644 --- a/Gemfile +++ b/Gemfile @@ -33,3 +33,5 @@ gem 'wdm', '~> 0.1.1', platforms: %i[mingw x64_mingw mswin] gem 'html-proofer', '~> 3.19' gem 'rake', '~> 13.0' + +gem 'webrick' diff --git a/Gemfile.lock b/Gemfile.lock index 62c7bf5..959397b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,6 +99,7 @@ GEM typhoeus (1.4.0) ethon (>= 0.9.0) unicode-display_width (1.7.0) + webrick (1.8.1) yell (2.2.2) PLATFORMS @@ -115,6 +116,7 @@ DEPENDENCIES tzinfo (~> 1.2) tzinfo-data wdm (~> 0.1.1) + webrick BUNDLED WITH 2.2.13 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..92b1707 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +# no version needed since 2020 + +services: + jekyll: + image: git.autonomic.zone/autonomic-cooperative/kcl-site:latest + volumes: + - .:/site + ports: + - '4000:4000' \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..13c9369 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +if [ ! -f Gemfile ]; then + echo "NOTE: hmm, I don't see a Gemfile so I don't think there's a jekyll site here" + echo "Either you didn't mount a volume, or you mounted it incorrectly." + echo "Be sure you're in your jekyll site root and use something like this to launch" + echo "" + echo "docker run -p 4000:4000 -v \$(pwd):/site bretfisher/jekyll-serve" + echo "" + echo "NOTE: To create a new site, you can use the sister image bretfisher/jekyll like:" + echo "" + echo "docker run -v \$(pwd):/site bretfisher/jekyll new ." + exit 1 +fi + +bundle install --retry 5 --jobs 20 + +exec "$@" \ No newline at end of file