🛠 Only generate docker image when Gemfile is updated

This commit is contained in:
Dan Jones 2020-02-20 17:13:35 -06:00
commit 939a28e5d8
2 changed files with 6 additions and 4 deletions

1
.gitignore vendored
View file

@ -10,3 +10,4 @@ node_modules
package.json package.json
_config.local.yml _config.local.yml
.image

View file

@ -1,18 +1,19 @@
.PHONY: all build-image serve clean .PHONY: all serve clean
export PATH := $(HOME)/bin:$(PATH):/usr/local/bin export PATH := $(HOME)/bin:$(PATH):/usr/local/bin
PORT ?= 4000 PORT ?= 4000
IMAGE=ruby-with-bundler:2.6.3-2.0.2 IMAGE=danjones000/danielrayjones/ruby-with-bundler:1.0.0
all: serve all: serve
build-image: .image: Gemfile Gemfile.lock
docker build -t $(IMAGE) . docker build -t $(IMAGE) .
docker image inspect $(IMAGE) | jq -r '.[0].Id' | tee .image
_config.local.yml: _config.local.yml:
touch $@ touch $@
_site/index.html: build-image _config.local.yml _site/index.html: .image _config.local.yml
docker run -u $(shell id -u) --rm -v $(shell pwd):/app -w /app $(IMAGE) bundle exec jekyll build -c '_config.yml,_config.local.yml' 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 serve: _site/index.html