2020-07-08 11:12:21 +00:00
|
|
|
#!/usr/bin/make
|
|
|
|
# Makefile readme (ru): <http://linux.yaroslavl.ru/docs/prog/gnu_make_3-79_russian_manual.html>
|
|
|
|
# Makefile readme (en): <https://www.gnu.org/software/make/manual/html_node/index.html#SEC_Contents>
|
|
|
|
|
|
|
|
SHELL = /bin/sh
|
|
|
|
|
|
|
|
DOCKER_BIN = $(shell command -v docker 2> /dev/null)
|
2020-07-08 17:15:53 +00:00
|
|
|
DC_BIN = $(shell command -v docker-compose 2> /dev/null)
|
|
|
|
|
|
|
|
DC_RUN_ARGS = --rm --user "$(shell id -u):$(shell id -g)"
|
2020-07-08 11:12:21 +00:00
|
|
|
APP_NAME = $(notdir $(CURDIR))
|
|
|
|
|
2020-07-08 17:15:53 +00:00
|
|
|
.PHONY : help install gen preview
|
2020-07-08 11:12:21 +00:00
|
|
|
.DEFAULT_GOAL : help
|
|
|
|
|
|
|
|
help: ## Show this help
|
|
|
|
@printf "\033[33m%s:\033[0m\n" 'Available commands'
|
|
|
|
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
|
|
|
|
2020-07-08 17:15:53 +00:00
|
|
|
install: ## Install all dependencies
|
|
|
|
$(DC_BIN) run $(DC_RUN_ARGS) app yarn install
|
|
|
|
|
|
|
|
gen: ## Generate error pages
|
|
|
|
$(DC_BIN) run $(DC_RUN_ARGS) app nodejs ./bin/generator.js -c ./config.json -o ./out
|
|
|
|
|
|
|
|
preview: ## Build docker image and start preview
|
2020-07-08 11:12:21 +00:00
|
|
|
$(DOCKER_BIN) build -f ./Dockerfile -t $(APP_NAME):local .
|
2020-07-08 17:15:53 +00:00
|
|
|
@printf "\n \e[30;42m %s \033[0m\n\n" 'Now open in your favorite browser <http://127.0.0.1:8081> and press CTRL+C for stopping'
|
2020-07-10 07:43:48 +00:00
|
|
|
$(DOCKER_BIN) run --rm -i -p 8081:8080 -e "TEMPLATE_NAME=l7-light" $(APP_NAME):local
|
2020-07-08 11:12:21 +00:00
|
|
|
|
|
|
|
shell: ## Start shell into container with node
|
2020-07-08 17:15:53 +00:00
|
|
|
$(DC_BIN) run $(DC_RUN_ARGS) app sh
|