2020-07-10 15:14:30 +00:00
|
|
|
#!/usr/bin/make -f
|
2020-09-25 20:36:46 +00:00
|
|
|
SHELL = bash
|
2020-07-10 15:14:30 +00:00
|
|
|
|
2020-09-25 20:36:46 +00:00
|
|
|
# Main environment configuration
|
2020-07-10 15:14:30 +00:00
|
|
|
include .env
|
2020-09-25 20:36:46 +00:00
|
|
|
|
2021-02-26 15:06:36 +00:00
|
|
|
# Optional variables with secrets
|
2020-07-10 15:14:30 +00:00
|
|
|
-include .secrets
|
|
|
|
|
2020-09-25 20:36:46 +00:00
|
|
|
# help target
|
2020-07-10 15:14:30 +00:00
|
|
|
include help.mk
|
|
|
|
|
2021-04-16 10:57:21 +00:00
|
|
|
# update NeoFS global config targets
|
|
|
|
include neofs_config.mk
|
|
|
|
|
2020-09-25 20:36:46 +00:00
|
|
|
# Targets to get required artifacts and external resources for each service
|
2020-07-10 15:14:30 +00:00
|
|
|
include services/*/artifacts.mk
|
|
|
|
|
2020-10-23 15:59:21 +00:00
|
|
|
# Targets helpful to prepare service environment
|
|
|
|
include services/*/prepare.mk
|
|
|
|
|
2020-07-10 15:14:30 +00:00
|
|
|
# Services that require artifacts
|
|
|
|
GET_SVCS = $(shell grep -Rl "get.*:" ./services/* | sort -u | grep artifacts.mk | xargs -I {} dirname {} | xargs basename -a)
|
|
|
|
|
|
|
|
# Services that require pulling images
|
|
|
|
PULL_SVCS = $(shell find ./services -type f -name 'docker-compose.yml' | sort -u | xargs -I {} dirname {} | xargs basename -a)
|
|
|
|
|
2020-09-25 20:36:46 +00:00
|
|
|
# List of services to run
|
2020-09-22 13:08:06 +00:00
|
|
|
START_SVCS = $(shell cat .services | grep -v \\\#)
|
|
|
|
STOP_SVCS = $(shell tac .services | grep -v \\\#)
|
2020-07-10 15:14:30 +00:00
|
|
|
|
2020-09-25 20:36:46 +00:00
|
|
|
# List of hosts available in devenv
|
2020-07-10 15:14:30 +00:00
|
|
|
HOSTS_LINES = $(shell grep -Rl IPV4_PREFIX ./services/* | grep .hosts)
|
|
|
|
|
2021-04-29 14:34:23 +00:00
|
|
|
# Paths to protocol.privnet.yml
|
|
|
|
MORPH_CHAIN_PROTOCOL = './services/morph_chain/protocol.privnet.yml'
|
|
|
|
CHAIN_PROTOCOL = './services/chain/protocol.privnet.yml'
|
|
|
|
|
|
|
|
# List of grepped environment variables from *.env
|
|
|
|
GREP_DOTENV = $(shell find . -name '*.env' -exec grep -rhv -e '^\#' -e '^$$' {} + )
|
2020-09-22 13:08:06 +00:00
|
|
|
|
2020-07-10 15:14:30 +00:00
|
|
|
# Pull all required Docker images
|
|
|
|
.PHONY: pull
|
|
|
|
pull:
|
|
|
|
$(foreach SVC, $(PULL_SVCS), $(shell cd services/$(SVC) && docker-compose pull))
|
|
|
|
@:
|
|
|
|
|
|
|
|
# Get all services artifacs
|
|
|
|
.PHONY: get
|
|
|
|
get: $(foreach SVC, $(GET_SVCS), get.$(SVC))
|
|
|
|
@:
|
|
|
|
|
2020-09-25 20:36:46 +00:00
|
|
|
# Start environment
|
2020-07-10 15:14:30 +00:00
|
|
|
.PHONY: up
|
2020-12-01 11:50:23 +00:00
|
|
|
up: pull get vendor/hosts
|
2021-06-29 19:53:09 +00:00
|
|
|
@$(foreach SVC, $(START_SVCS), $(shell docker-compose -f services/$(SVC)/docker-compose.yml up -d))
|
|
|
|
@./bin/tick.sh
|
|
|
|
@echo "NeoFS Developer Environment is ready"
|
2020-07-10 15:14:30 +00:00
|
|
|
|
2020-09-25 20:36:46 +00:00
|
|
|
# Stop environment
|
2020-07-10 15:14:30 +00:00
|
|
|
.PHONY: down
|
|
|
|
down:
|
|
|
|
$(foreach SVC, $(STOP_SVCS), $(shell docker-compose -f services/$(SVC)/docker-compose.yml down))
|
|
|
|
|
2020-09-24 09:34:19 +00:00
|
|
|
.PHONY: vendor/hosts
|
2021-01-13 10:25:37 +00:00
|
|
|
.ONESHELL:
|
2020-09-24 09:34:19 +00:00
|
|
|
vendor/hosts:
|
2021-01-13 10:25:37 +00:00
|
|
|
@for file in $(HOSTS_LINES)
|
|
|
|
do
|
|
|
|
while read h
|
|
|
|
do
|
|
|
|
echo $${h} | \
|
|
|
|
sed 's|IPV4_PREFIX|$(IPV4_PREFIX)|g' | \
|
|
|
|
sed 's|LOCAL_DOMAIN|$(LOCAL_DOMAIN)|g'
|
|
|
|
done < $${file};
|
2020-09-24 09:34:19 +00:00
|
|
|
done > $@
|
|
|
|
|
|
|
|
# Display changes for /etc/hosts
|
|
|
|
.PHONY: hosts
|
|
|
|
hosts: vendor/hosts
|
|
|
|
@cat vendor/hosts
|
2020-12-01 11:50:23 +00:00
|
|
|
|
2021-02-26 15:06:36 +00:00
|
|
|
# Clean-up the environment
|
2020-12-01 11:50:23 +00:00
|
|
|
.PHONY: clean
|
2021-01-13 10:28:19 +00:00
|
|
|
.ONESHELL:
|
2020-12-01 11:50:23 +00:00
|
|
|
clean:
|
2021-06-10 13:25:02 +00:00
|
|
|
@rm -rf vendor/* services/storage/s04tls.*
|
2021-01-13 10:28:19 +00:00
|
|
|
@for svc in $(START_SVCS)
|
|
|
|
do
|
|
|
|
vols=`docker-compose -f services/$${svc}/docker-compose.yml config --volumes`
|
|
|
|
if [[ ! -z "$${vols}" ]]; then
|
|
|
|
for vol in $${vols}; do
|
|
|
|
docker volume rm "$${svc}_$${vol}" 2> /dev/null
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
2021-04-29 14:34:23 +00:00
|
|
|
|
|
|
|
# Generate environment
|
|
|
|
.PHONY: env
|
|
|
|
env:
|
|
|
|
@$(foreach envvar,$(GREP_DOTENV),echo $(envvar);)
|
|
|
|
@echo MORPH_BLOCK_TIME=$(shell grep 'SecondsPerBlock' $(MORPH_CHAIN_PROTOCOL) | awk '{print $$2}')s
|
|
|
|
@echo MAINNET_BLOCK_TIME=$(shell grep 'SecondsPerBlock' $(CHAIN_PROTOCOL) | awk '{print $$2}')s
|
2021-06-30 10:49:24 +00:00
|
|
|
@echo MORPH_MAGIC=$(shell grep 'Magic' $(MORPH_CHAIN_PROTOCOL) | awk '{print $$2}')
|
2021-07-22 17:15:59 +00:00
|
|
|
|
|
|
|
# Restart storage nodes with clean volumes
|
|
|
|
.PHONY: restart.storage-clean
|
|
|
|
restart.storage-clean:
|
|
|
|
@docker-compose -f ./services/storage/docker-compose.yml down
|
|
|
|
@$(foreach vol, \
|
|
|
|
$(shell docker-compose -f services/storage/docker-compose.yml config --volumes),\
|
|
|
|
docker volume rm storage_$(vol);)
|
|
|
|
@docker-compose -f ./services/storage/docker-compose.yml up -d
|
|
|
|
|