forked from elastic/opbeans-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (40 loc) · 2.04 KB
/
Makefile
File metadata and controls
54 lines (40 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
update-frontend: ## Update opbeans-fronted repo
-test ! -d client && git clone https://github.com/elastic/opbeans-frontend client
cd client && git pull
compile-frontend: ## Compile opbeans-fronted project and copy artifacts
cd client && npm --no-bin-links install && npm run-script build
rm -rf $(ROOT_DIR)/opbeans/static && \
mkdir -p $(ROOT_DIR)/opbeans/static/build && \
cp -r $(ROOT_DIR)/client/build/* $(ROOT_DIR)/opbeans/static/build && \
cp -r $(ROOT_DIR)/client/package.json $(ROOT_DIR)/opbeans/static/
sed 's/<head>/<head>{% block head %}{% endblock %}/' $(ROOT_DIR)/client/build/index.html | sed 's/<script type="text\/javascript" src="\/rum-config.js"><\/script>//' > $(ROOT_DIR)/opbeans/templates/base.html
frontend: | update-frontend compile-frontend
.PHONY: frontend update-frontend compile-frontend push-image help
PORT ?= 3000
IMAGE ?= opbeans/opbeans-python
VERSION ?= latest
LTS_ALPINE ?= 12-alpine
.DEFAULT_GOAL := help
help: ## Display this help text
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
all: build test
build: ## Build docker image
@docker build --file Dockerfile --tag=${IMAGE}:${VERSION} .
bats: ## Install bats in the project itself
@git clone https://github.com/sstephenson/bats.git
prepare-test: bats ## Prepare the bats dependencies
@docker pull node:${LTS_ALPINE}
@mkdir -p target
@git submodule sync
@git submodule update --init --recursive
test: prepare-test ## Run the tests
@echo "Tests are in progress, please be patient"
@PORT=${PORT} bats/bin/bats --tap tests | tee target/results.tap
@docker run --rm -v "${PWD}":/usr/src/app -w /usr/src/app node:${LTS_ALPINE} \
sh -c "npm install tap-xunit -g && cat target/results.tap | tap-xunit --package='co.elastic.opbeans' > target/junit-results.xml"
publish: build ## Publish docker image
@docker push "${IMAGE}:${VERSION}"
clean: ## Clean autogenerated files/folders
@rm -rf bats
@rm -rf target