From 7473f35247ba0c998c294bf2137cc1c389d179f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=B6ller?= Date: Mon, 6 Nov 2023 13:23:43 +0100 Subject: [PATCH] Use custom build image (#5) which supports ARM cpus as well --- .github/workflows/pr.yml | 16 +++++++++++++++ docker/Dockerfile | 16 +++++++++++++++ Gemfile => docker/Gemfile | 0 Gemfile.lock => docker/Gemfile.lock | 4 ++-- go.sh | 30 +++++++++++++++-------------- 5 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/pr.yml create mode 100644 docker/Dockerfile rename Gemfile => docker/Gemfile (100%) rename Gemfile.lock => docker/Gemfile.lock (98%) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..954b539 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,16 @@ +name: PR build + +on: [pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build with Jekyll + # Outputs to the './_site' directory by default + run: | + mkdir -p _site + ./go.sh build diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..66168ab --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,16 @@ +FROM ruby:2.7 + +ENV BUNDLE_GEMFILE=/app/bundle/Gemfile + +WORKDIR /app/bundle + +ADD Gemfile . +ADD Gemfile.lock . + +RUN bundle install + +RUN mkdir /app/src + +WORKDIR /app/src + +ENTRYPOINT ["bundle", "exec", "jekyll"] diff --git a/Gemfile b/docker/Gemfile similarity index 100% rename from Gemfile rename to docker/Gemfile diff --git a/Gemfile.lock b/docker/Gemfile.lock similarity index 98% rename from Gemfile.lock rename to docker/Gemfile.lock index b7c4c18..25b9f6d 100644 --- a/Gemfile.lock +++ b/docker/Gemfile.lock @@ -15,7 +15,7 @@ GEM eventmachine (>= 0.12.9) http_parser.rb (~> 0) eventmachine (1.2.7) - ffi (1.16.1) + ffi (1.16.3) forwardable-extended (2.6.0) http_parser.rb (0.8.0) i18n (0.9.5) @@ -89,4 +89,4 @@ DEPENDENCIES wdm (~> 0.1.0) BUNDLED WITH - 2.0.2 + 2.1.4 diff --git a/go.sh b/go.sh index ef148ac..c564e17 100755 --- a/go.sh +++ b/go.sh @@ -5,23 +5,24 @@ set -e export JEKYLL_VERSION=3.8 goal_serve() { - docker run --rm \ - --volume="$PWD:/srv/jekyll:Z" \ - --volume="$PWD/vendor/bundle:/usr/local/bundle:Z" \ - --env FORCE_POLLING=true \ - -p 4000:4000 \ - -p 40000:40000 \ - -it jekyll/builder:$JEKYLL_VERSION \ - jekyll serve --drafts --livereload --livereload_port 40000 --force_polling --incremental + goal_docker + + docker run --rm -p 4000:4000 -p 40000:40000 -v $(pwd):/app/src jekyll-container serve\ + --host 0.0.0.0 --drafts --livereload --livereload_port 40000 --force_polling } goal_build() { - docker run --rm \ - --volume="$PWD:/srv/jekyll:Z" \ - --volume="$PWD/vendor/bundle:/usr/local/bundle:Z" \ - --env JEKYLL_ENV=production \ - jekyll/builder:$JEKYLL_VERSION \ - jekyll build + goal_docker + rm -rf _site + docker run --rm -p 4000:4000 -p 40000:40000 --env JEKYLL_ENV=production -v $(pwd):/app/src jekyll-container build + + +} + +goal_docker() { + docker build -t jekyll-container docker + + docker run --rm --entrypoint cat jekyll-container /app/bundle/Gemfile.lock > docker/Gemfile.lock } goal_help() { @@ -29,6 +30,7 @@ goal_help() { available goals serve -- serve the blog locally (http://localhost:4000) build -- build the blog (builds static artifact for publishing) + docker -- creates docker build image (tag: jekyll-container) " exit 1 }