-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
81 lines (66 loc) · 1.81 KB
/
Makefile
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
STAGE ?= dev
FORCE_PUSH_OVERRIDE ?= 0
IMAGE_NAME = knplabs/server-side-renderer
.PHONY: dev
dev: cp-env start
$(MAKE) install-deps
.PHONY: start
start:
docker-compose -f docker-compose.${STAGE}.yaml build
docker-compose -f docker-compose.${STAGE}.yaml up -d
.PHONY: stop
stop:
docker-compose -f docker-compose.${STAGE}.yaml down
.PHONY: test
test:
ifndef CI
docker-compose -f docker-compose.${STAGE}.yaml run --rm test yarn test
else
docker-compose -f docker-compose.${STAGE}.yaml run --rm test yarn test-ci
endif
.PHONY: build
build: .validate-tag
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
.PHONY: push
push: .validate-tag .block-image-override
docker image push ${IMAGE_NAME}:${IMAGE_TAG}
.PHONY: push-latest
push-latest: .validate-tag
docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${IMAGE_NAME}:latest
docker image push ${IMAGE_NAME}:latest
.PHONY: cp-env
cp-env:
ifeq ($(STAGE),dev)
cp -n .env.dist .env
endif
.PHONY: install-deps
install-deps:
ifeq ($(STAGE),dev)
docker-compose -f docker-compose.dev.yaml run --rm manager yarn install
else
@echo "You can't install app dependencies on non-dev environments.\n"
@exit 1
endif
.PHONY: .validate-tag
.validate-tag:
ifeq ($(IMAGE_TAG),)
@echo "You can't build and push without an IMAGE_TAG.\n"
@exit 1
endif
.PHONY: .block-image-override
.block-image-override:
ifeq ($(FORCE_PUSH_OVERRIDE),0)
@if $$(docker buildx imagetools inspect ${IMAGE_NAME}:${IMAGE_TAG} >/dev/null 2>&1); then \
echo "Image ${IMAGE_NAME} with tag ${IMAGE_TAG} found on remote registry."; \
exit 1; \
fi;
endif
.PHONY: lint-dockerfiles
lint-dockerfiles:
docker run --rm -i hadolint/hadolint < Dockerfile
.PHONY: lint-js
lint-js:
docker-compose -f docker-compose.$(STAGE).yaml run --rm test yarn lint
.PHONY: fix-js
fix-js:
docker-compose -f docker-compose.$(STAGE).yaml run --rm test yarn lint --fix