From 9f1dd6284be7d05b61dbb5defe21757adf942d12 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 18 Apr 2020 19:44:48 +0200 Subject: [PATCH] Add `make stop` and allow --incremental [ci skip] --- CONTRIBUTING.md | 10 ++++++++-- Makefile | 28 ++++++++++++++++++++-------- sbin/entrypoint.sh | 15 +++++++++------ 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 436aeef..eea0443 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,13 +24,13 @@ The only prerequisite is [Docker](https://www.docker.com/). If you're on Debian, ```bash $ curl -fsSL https://get.docker.com -o get-docker.sh # have a look if you want -$ sh get-docker.sh +$ CHANNEL=stable sh get-docker.sh ``` Fire up the container with the following. ```bash -$ make dockerserver +$ make serve ``` Then visit the locally running website. @@ -39,6 +39,12 @@ Then visit the locally running website. Then you can edit the files as normal and reload the page. +To stop the container when you're done, you can run: + +```bash +$ make stop +``` + ## Notes 1. For configuration, please note, we now use a `dev` environment config file: diff --git a/Makefile b/Makefile index 2c076da..6c79826 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,26 @@ -dockerbuild: - @docker build -t autonomic/autonomic.zone:testing . -.PHONY: dockerbuild +IMG := autonomic/autonomic.zone +NAME := autonomic-zone-testing +PORT := 4000 +TAG := testing -dockerserver: dockerbuild +build: + @docker build -t $(IMG):$(TAG) . +.PHONY: build + +stop: + @docker stop $(NAME) && docker rm $(NAME) --force +.PHONY: stop + +serve: build @docker run \ - -e JEKYLL_PORT=4000 \ + --name $(NAME) \ + -e JEKYLL_PORT=$(PORT) \ -e JEKYLL_HOST=0.0.0.0 \ -e JEKYLL_CONFIG=_config_dev.yml \ + -e JEKYLL_ENV=development \ -v $$(pwd):/usr/src/app \ - -p 4000:4000 \ + -p $(PORT):$(PORT) \ -d \ - autonomic/autonomic.zone:testing -.PHONY: dockerserver + $(IMG):$(TAG) && \ + echo "Site available at http://localhost:4000" +.PHONY: serve diff --git a/sbin/entrypoint.sh b/sbin/entrypoint.sh index e0607c4..c34a296 100755 --- a/sbin/entrypoint.sh +++ b/sbin/entrypoint.sh @@ -6,12 +6,15 @@ set -eu -o pipefail run_jekyll() { set -eu - bundle exec jekyll serve \ - --config "$JEKYLL_CONFIG" \ - --host "$JEKYLL_HOST" \ - --port "$JEKYLL_PORT" \ - --trace \ - --verbose + # shellcheck disable=SC2155 + local args="--config $JEKYLL_CONFIG --host $JEKYLL_HOST --port $JEKYLL_PORT --trace --verbose" + + if [[ $JEKYLL_ENV == "development" ]]; then + # shellcheck disable=SC2155 + local args="${args} --incremental" + fi + + bundle exec jekyll serve $args } # Main entrypoint