From 580e34f9eb3c2fff64e637b6445b677c8e37f7de Mon Sep 17 00:00:00 2001 From: Ryan Prior Date: Sun, 5 Apr 2020 14:49:34 -0500 Subject: [PATCH 1/3] Adds Dockerized build environment & scripts --- Dockerfile | 27 +++++++++++++++++++++++++++ bin/build-container | 4 ++++ bin/serve | 7 +++++++ 3 files changed, 38 insertions(+) create mode 100644 Dockerfile create mode 100755 bin/build-container create mode 100755 bin/serve diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..d2aa666b5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM ruby:2.7-buster + +# Install program to configure locales as per +# https://github.com/jekyll/jekyll/issues/4268#issuecomment-167406574 +RUN apt-get update && apt-get install -y locales +RUN dpkg-reconfigure locales && \ + locale-gen C.UTF-8 && \ + /usr/sbin/update-locale LANG=C.UTF-8 + +# Install needed default locale for Makefly +RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && locale-gen + +# Set default locale for the environment +ENV LC_ALL C.UTF-8 +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US.UTF-8 + +RUN mkdir -p /opt/io/elementary/releases +WORKDIR /opt/io/elementary/releases + +COPY Gemfile ./ +RUN gem install jekyll && bundle install + +ENTRYPOINT ["/usr/local/bin/bundle", "exec", \ + "jekyll", "serve", \ + "--host", "0.0.0.0", \ + "--port", "4000"] diff --git a/bin/build-container b/bin/build-container new file mode 100755 index 000000000..775f3afdd --- /dev/null +++ b/bin/build-container @@ -0,0 +1,4 @@ +#!/bin/bash + +cd $(git rev-parse --show-toplevel) # work from repo dir +docker build -t io.elementary.releases . diff --git a/bin/serve b/bin/serve new file mode 100755 index 000000000..eba7fc2bc --- /dev/null +++ b/bin/serve @@ -0,0 +1,7 @@ +#!/bin/bash + +cd $(git rev-parse --show-toplevel) # work from repo dir +docker run --rm -it \ + -v $(pwd):/opt/io/elementary/releases/ \ + -p 4000:4000 \ + io.elementary.releases From ce85247ed8ad39959c59a90145250319d989ed0b Mon Sep 17 00:00:00 2001 From: Ryan Prior Date: Sun, 5 Apr 2020 14:54:02 -0500 Subject: [PATCH 2/3] Updates README with Docker build instructions --- README.md | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 88543ad9d..b136aca95 100644 --- a/README.md +++ b/README.md @@ -12,28 +12,44 @@ zlib1g-dev ``` We recommend installing gems to a (hidden) directory in your home folder: -```bash -echo '' >> ~/.bashrc -echo '# Install Ruby Gems to ~/.gems' >> ~/.bashrc -echo 'export GEM_HOME="$HOME/.gems"' >> ~/.bashrc -echo 'export PATH="$HOME/.gems/bin:$PATH"' >> ~/.bashrc -echo '' >> ~/.bashrc -source ~/.bashrc +```sh-session +$ echo '' >> ~/.bashrc +$ echo '# Install Ruby Gems to ~/.gems' >> ~/.bashrc +$ echo 'export GEM_HOME="$HOME/.gems"' >> ~/.bashrc +$ echo 'export PATH="$HOME/.gems/bin:$PATH"' >> ~/.bashrc +$ echo '' >> ~/.bashrc +$ source ~/.bashrc ``` Install jekyll and bundler: -```bash -gem install jekyll bundler +```sh-session +$ gem install jekyll bundler ``` Install gems: -```bash -bundle install +```sh-session +$ bundle install ``` Build and serve locally with: -```bash -bundle exec jekyll serve --host 0.0.0.0 +```sh-session +$ bundle exec jekyll serve --host 0.0.0.0 ``` The site should now be available at http://0.0.0.0:4000/ on your local machine, and your local machine's IP address on your network—great for testing on mobile OSes. + +### Alternative: building with Docker + +You'll need Docker installed on your system. + +Build the Docker image: +```sh-session +$ bin/build-container +``` + +Build and serve locally with: +```sh-session +$ bin/serve +``` + +The site should now be available at http://0.0.0.0:4000/ From 17ded1582b4a5c1ef2bdb0b14d0daf879876e04c Mon Sep 17 00:00:00 2001 From: Ryan Prior Date: Sat, 9 Oct 2021 11:06:03 -0500 Subject: [PATCH 3/3] Updates Dockerfile to use upstream `jekyll/jekyll` Docker image --- Dockerfile | 19 +++---------------- bin/serve | 2 +- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index d2aa666b5..81494e2ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,12 @@ -FROM ruby:2.7-buster - -# Install program to configure locales as per -# https://github.com/jekyll/jekyll/issues/4268#issuecomment-167406574 -RUN apt-get update && apt-get install -y locales -RUN dpkg-reconfigure locales && \ - locale-gen C.UTF-8 && \ - /usr/sbin/update-locale LANG=C.UTF-8 - -# Install needed default locale for Makefly -RUN echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && locale-gen +FROM jekyll/jekyll:4 # Set default locale for the environment ENV LC_ALL C.UTF-8 ENV LANG en_US.UTF-8 ENV LANGUAGE en_US.UTF-8 -RUN mkdir -p /opt/io/elementary/releases -WORKDIR /opt/io/elementary/releases - -COPY Gemfile ./ -RUN gem install jekyll && bundle install +COPY Gemfile Gemfile.lock ./ +RUN bundle install ENTRYPOINT ["/usr/local/bin/bundle", "exec", \ "jekyll", "serve", \ diff --git a/bin/serve b/bin/serve index eba7fc2bc..b4a597f03 100755 --- a/bin/serve +++ b/bin/serve @@ -2,6 +2,6 @@ cd $(git rev-parse --show-toplevel) # work from repo dir docker run --rm -it \ - -v $(pwd):/opt/io/elementary/releases/ \ + -v $(pwd):/srv/jekyll/ \ -p 4000:4000 \ io.elementary.releases