forked from fluencelabs/nox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
71 lines (60 loc) · 2.33 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
# Usage:
# make node TAG=v1.2.3
# TAG is optional
# tag defaults to latest
TAG ?= latest
ENV ?= stage
# enable docker kit
KIT = DOCKER_BUILDKIT=1
BUILD = $(KIT) docker build
QUIET = --quiet
TEST_ENV = environment=test
TEST = $(QUIET) --build-arg $(TEST_ENV)
TRAVIS ?= false
DIR = tools/docker
NODE_FILE = Node.Dockerfile
WORK_FILE = Worker.Dockerfile
DASH_FILE = Dashboard.Dockerfile
NODE_IMG = 'fluencelabs/node:$(TAG)'
WORK_IMG = 'fluencelabs/worker:$(TAG)'
DASH_IMG = 'fluencelabs/dashboard:$(TAG)'
######### Build tasks #########
node: ;$(BUILD) -t $(NODE_IMG) -f $(DIR)/$(NODE_FILE) .
worker: ;$(BUILD) -t $(WORK_IMG) -f $(DIR)/$(WORK_FILE) .
dashboard: ;$(BUILD) -t $(DASH_IMG) -f $(DIR)/$(DASH_FILE) .
ifeq ($(TRAVIS), false)
node-test: ;$(BUILD) $(TEST) -t $(NODE_IMG) -f $(DIR)/$(NODE_FILE) .
worker-test: ;$(BUILD) $(TEST) -t $(WORK_IMG) -f $(DIR)/$(WORK_FILE) .
endif
# Using buildctl here because TravisCI doesn't support BuildKit
# (see https://travis-ci.community/t/docker-builds-are-broken-if-buildkit-is-used-docker-buildkit-1/2994)
ifeq ($(TRAVIS), true)
node-test: NODE-bctl-test
worker-test: WORK-bctl-test
endif
# $* becomes what matched by % in `%-bctl-test`: NODE or WORK
%-bctl-test: ;buildctl build \
--frontend dockerfile.v0 \
--local context=. \
--local dockerfile=$(DIR) \
--opt filename=$($*_FILE) \
--opt build-arg:$(TEST_ENV) \
--output type=docker,name=$($*_IMG) | docker load
######### Deployment tasks #########
# Deploy from existing assembly jars
deploy-prebuilt: push-local deploy
# Rebuild jars and deploy
deploy-rebuild: jars push-local deploy
# Build containers in docker build environment
deploy-clean: push-clean deploy
deploy: ;cd tools/deploy; fab --set environment=$(ENV),image_tag=$(TAG) deploy
push: push-node push-worker
# Build containers from existing jars and publish
push-local: node-test worker-test; $(MAKE) push
# Build containers in docker build environment and publish
push-clean: node worker; $(MAKE) push
push-node: ;docker push $(NODE_IMG)
push-worker: ;docker push $(WORK_IMG)
# Build jars
jars: ;sbt node/assembly statemachine-docker/assembly
.PHONY: node node-test worker worker-test dashboard %-bctl-test deploy