From 1be0d5fb444ad26eba206d49c3346449b61e6021 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Mon, 19 Aug 2019 11:29:07 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=B3=20Use=20docker=20to=20test=20local?= =?UTF-8?q?ly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 7 +++++++ Makefile | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cd2b5f4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM ruby:2.6.3 + +RUN gem install bundler:2.0.2 && \ + bundle config --global frozen 1 + +COPY Gemfile Gemfile.lock ./ +RUN bundle install diff --git a/Makefile b/Makefile index 023f284..2656541 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,19 @@ +.PHONY: all build-image serve clean + export PATH := $(HOME)/bin:$(PATH):/usr/local/bin -IP ?= 127.0.0.1 PORT ?= 4000 +IMAGE=ruby-with-bundler:2.6.3-2.0.2 all: serve -stage: - bundle exec jekyll build -c '_config.yml,_config.local.yml' +build-image: + docker build -t $(IMAGE) . -serve: - bundle exec jekyll serve -H "$(IP)" -P "$(PORT)" -c '_config.yml,_config.local.yml' +_site/index.html: build-image + docker run -u $(shell id -u) --rm -v $(shell pwd):/app -w /app $(IMAGE) bundle exec jekyll build -c '_config.yml,_config.local.yml' + +serve: _site/index.html + docker run --rm -it -v $(shell pwd):/app -w /app -p $(PORT):$(PORT) $(IMAGE) bundle exec jekyll serve -H 0.0.0.0 -P "$(PORT)" -c '_config.yml,_config.local.yml' + +clean: + rm -rf _site