2022-02-21 12:57:35 -05:00
|
|
|
IGNORED := $(shell grep -v testenv .gitignore)
|
2019-10-18 00:50:15 -04:00
|
|
|
VOLUME_ARG =
|
2022-09-03 20:05:31 -04:00
|
|
|
COMPOSE_V2 := $(shell $(SHELL) -c "docker compose; exit 0" 2>&1 1>/dev/null)
|
|
|
|
ifndef COMPOSE_V2
|
2022-08-28 13:11:28 -04:00
|
|
|
COMPOSE_COMMAND = docker compose
|
|
|
|
else
|
2022-09-03 20:05:31 -04:00
|
|
|
COMPOSE_V1 := $(shell command -v docker-compose)
|
|
|
|
ifdef COMPOSE_V1
|
|
|
|
COMPOSE_COMMAND = docker-compose
|
|
|
|
endif
|
2022-08-28 13:11:28 -04:00
|
|
|
endif
|
2016-09-06 23:19:12 -04:00
|
|
|
|
2019-03-20 01:53:14 -04:00
|
|
|
.PHONY: all
|
|
|
|
all:
|
|
|
|
@$(MAKE) usage | less
|
2016-09-06 23:19:12 -04:00
|
|
|
|
2019-03-20 01:53:14 -04:00
|
|
|
# Display usage for all make targets
|
|
|
|
.PHONY: usage
|
|
|
|
usage:
|
|
|
|
@echo
|
|
|
|
@echo 'make TARGET'
|
|
|
|
@echo
|
|
|
|
@echo 'TESTING'
|
|
|
|
@echo
|
|
|
|
@echo ' make test'
|
2019-03-21 23:54:05 -04:00
|
|
|
@echo ' - Perform tests done by continuous integration.'
|
2019-03-20 01:53:14 -04:00
|
|
|
@echo ' This target will:'
|
|
|
|
@echo ' - Remove previously built data'
|
|
|
|
@echo ' - Build the site'
|
|
|
|
@echo ' - Test the site using html-proofer'
|
|
|
|
@echo
|
|
|
|
@echo ' make up'
|
|
|
|
@echo ' - Start a container to locally test the website.'
|
|
|
|
@echo ' This target will:'
|
|
|
|
@echo ' - Start a jekyll container (re-using it if it already exists)'
|
|
|
|
@echo ' - Expose the website on port 4000 of the local host'
|
|
|
|
@echo
|
|
|
|
@echo ' make logs'
|
|
|
|
@echo ' - Tail the logs of the running jekyll container.'
|
|
|
|
@echo
|
|
|
|
@echo ' make restart'
|
|
|
|
@echo ' - Restart the jekyll container.'
|
|
|
|
@echo
|
|
|
|
@echo ' make down'
|
|
|
|
@echo ' - Shutdown and remove the jekyll container.'
|
|
|
|
@echo
|
|
|
|
@echo ' make clean'
|
2019-07-29 09:20:05 -04:00
|
|
|
@echo ' - Remove previously built data and any jekyll containers.'
|
2019-03-20 01:53:14 -04:00
|
|
|
@echo
|
2019-10-18 00:50:15 -04:00
|
|
|
@echo ' make fresh'
|
|
|
|
@echo ' - Like "make clean", but also removes the docker volumes.'
|
|
|
|
@echo
|
2019-03-20 01:53:14 -04:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test: require-docker-compose clean
|
2022-08-28 13:11:28 -04:00
|
|
|
$(COMPOSE_COMMAND) run --rm website test/validate
|
2019-03-20 01:53:14 -04:00
|
|
|
|
|
|
|
.PHONY: up
|
|
|
|
up: require-docker-compose
|
2022-08-28 13:11:28 -04:00
|
|
|
$(COMPOSE_COMMAND) up --no-recreate -d
|
2019-03-20 01:53:14 -04:00
|
|
|
@echo
|
|
|
|
@echo Started docker container. It will probably take a bit of time before
|
|
|
|
@echo the webserver is listening. You can run \"make logs\" to watch the logs
|
|
|
|
@echo of this container.
|
|
|
|
@echo
|
|
|
|
@echo The site will be served at http://0.0.0.0:4000/
|
|
|
|
|
|
|
|
.PHONY: logs
|
|
|
|
logs: require-docker-compose
|
2022-08-28 13:11:28 -04:00
|
|
|
$(COMPOSE_COMMAND) logs --tail 0 -f
|
2019-03-20 01:53:14 -04:00
|
|
|
|
|
|
|
.PHONY: restart
|
|
|
|
restart: require-docker-compose
|
2022-08-28 13:11:28 -04:00
|
|
|
$(COMPOSE_COMMAND) restart
|
2019-03-20 01:53:14 -04:00
|
|
|
|
|
|
|
.PHONY: down
|
|
|
|
down: require-docker-compose
|
2022-08-28 13:11:28 -04:00
|
|
|
$(COMPOSE_COMMAND) down --remove-orphans ${VOLUME_ARG}
|
2019-03-20 01:53:14 -04:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean: down
|
|
|
|
rm -rf ${IGNORED}
|
|
|
|
|
2019-10-18 00:50:15 -04:00
|
|
|
.PHONY: fresh
|
|
|
|
fresh: VOLUME_ARG = -v
|
|
|
|
fresh: clean
|
|
|
|
|
2019-03-20 01:53:14 -04:00
|
|
|
.PHONY: require-docker-compose
|
|
|
|
require-docker-compose: require-docker
|
2022-09-03 20:05:31 -04:00
|
|
|
@if [ -z "$(COMPOSE_COMMAND)" ]; then \
|
|
|
|
echo "Sorry, this make target requires docker compose to be supported."; \
|
|
|
|
false; \
|
2019-03-20 01:53:14 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
.PHONY: require-docker
|
|
|
|
require-docker:
|
|
|
|
@if ! command -v "docker" >/dev/null 2>&1; then \
|
|
|
|
echo "Sorry, this make target requires docker to be installed."; \
|
|
|
|
false; \
|
|
|
|
fi
|