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
|
|
|
|
|
2022-12-21 12:34:14 +00:00
|
|
|
# update FrostFS global config targets
|
|
|
|
include frostfs_config.mk
|
2021-04-16 10:57:21 +00:00
|
|
|
|
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-09-25 20:36:46 +00:00
|
|
|
# List of services to run
|
2022-10-21 22:09:27 +00:00
|
|
|
START_SVCS = $(shell cat .services | grep -v '#')
|
|
|
|
START_BASIC = $(shell cat .basic_services | grep -ve '#')
|
|
|
|
START_BOOTSTRAP = $(shell cat .bootstrap_services | grep -v '#')
|
|
|
|
STOP_SVCS = $(shell tac .services | grep -v '#')
|
|
|
|
STOP_BASIC = $(shell tac .basic_services | grep -v '#')
|
|
|
|
STOP_BOOTSTRAP = $(shell tac .bootstrap_services | grep -v '#')
|
2020-07-10 15:14:30 +00:00
|
|
|
|
2022-10-14 09:39:30 +00:00
|
|
|
# Enabled services dirs
|
|
|
|
ENABLED_SVCS_DIRS = $(shell echo "${START_BOOTSTRAP} ${START_BASIC} ${START_SVCS}" | sed 's|[^ ]* *|./services/&|g')
|
|
|
|
|
|
|
|
# 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 ${ENABLED_SVCS_DIRS} -type f -name 'docker-compose.yml' | sort -u | xargs -I {} dirname {} | xargs basename -a)
|
|
|
|
|
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'
|
|
|
|
|
|
|
|
# List of grepped environment variables from *.env
|
2023-05-03 08:46:38 +00:00
|
|
|
GREP_DOTENV = $(shell find . -name '*.env' -exec grep -rhv -e '^#' -e '^$$' {} + | sort -u )
|
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))
|
|
|
|
@:
|
|
|
|
|
2022-10-12 14:04:37 +00:00
|
|
|
# Get all services artifacts
|
2020-07-10 15:14:30 +00:00
|
|
|
.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
|
2022-02-04 15:27:49 +00:00
|
|
|
up: up/basic
|
2021-06-29 19:53:09 +00:00
|
|
|
@$(foreach SVC, $(START_SVCS), $(shell docker-compose -f services/$(SVC)/docker-compose.yml up -d))
|
2024-09-30 14:04:11 +00:00
|
|
|
./vendor/frostfs-adm morph proxy-add-account --config frostfs-adm.yml --account=`docker container exec morph_chain neo-go wallet dump-keys -w /wallets/s3-wallet.json | head -1 | awk '{print $1}'` || die "Couldn't set s3-gw wallet as proxy wallet"
|
2022-12-21 12:34:14 +00:00
|
|
|
@echo "Full FrostFS Developer Environment is ready"
|
2022-02-04 15:27:49 +00:00
|
|
|
|
2022-12-21 12:34:14 +00:00
|
|
|
# Build up FrostFS
|
2022-02-04 15:27:49 +00:00
|
|
|
.PHONY: up/basic
|
2022-09-09 14:39:24 +00:00
|
|
|
up/basic: up/bootstrap
|
2022-02-04 15:27:49 +00:00
|
|
|
@$(foreach SVC, $(START_BASIC), $(shell docker-compose -f services/$(SVC)/docker-compose.yml up -d))
|
2023-04-28 08:24:32 +00:00
|
|
|
@./vendor/frostfs-adm -c ./frostfs-adm.yml morph force-new-epoch
|
|
|
|
@./vendor/frostfs-adm -c ./frostfs-adm.yml morph set-config SystemDNS=container --force
|
2022-12-21 12:34:14 +00:00
|
|
|
@echo "Basic FrostFS Developer Environment is ready"
|
2022-02-04 15:27:49 +00:00
|
|
|
|
2022-09-09 14:39:24 +00:00
|
|
|
# Start bootstrap services
|
|
|
|
.PHONY: up/bootstrap
|
|
|
|
up/bootstrap: get vendor/hosts
|
|
|
|
@$(foreach SVC, $(START_BOOTSTRAP), $(shell docker-compose -f services/$(SVC)/docker-compose.yml up -d))
|
2022-11-03 12:13:05 +00:00
|
|
|
@source ./bin/helper.sh
|
2023-04-28 08:24:32 +00:00
|
|
|
@./vendor/frostfs-adm --config frostfs-adm.yml morph init --contracts vendor/contracts
|
2024-02-22 09:41:55 +00:00
|
|
|
echo "Set rule chain to policy contract"
|
|
|
|
@./vendor/frostfs-adm --config frostfs-adm.yml morph \
|
|
|
|
ape add-rule-chain --target-type namespace --target-name "" \
|
|
|
|
--rule 'allow Container.* *' --chain-id "allow_container_ops"
|
2023-04-28 08:22:37 +00:00
|
|
|
@for f in ./services/storage/wallet*.json; do \
|
|
|
|
echo "Transfer GAS to wallet $${f}" \
|
|
|
|
&& ./vendor/frostfs-adm -c frostfs-adm.yml morph refill-gas --storage-wallet $${f} --gas 10.0 \
|
|
|
|
|| die "Failed to transfer GAS to alphabet wallets"; \
|
2024-12-20 13:08:25 +00:00
|
|
|
echo "Register storage wallet $${f} in proxy contract" \
|
|
|
|
&& ./vendor/frostfs-adm morph proxy-add-account --config frostfs-adm.yml --account=`docker container exec morph_chain neo-go wallet dump-keys -w /wallets/storage/$${f##*/} | head -1 | awk '{print $1}'` || die "Couldn't set storage allet as proxy wallet"
|
2023-04-28 08:22:37 +00:00
|
|
|
done
|
2024-08-17 05:08:24 +00:00
|
|
|
@echo "Create frostfsid subject for ./wallets/wallet.json"; \
|
|
|
|
if [ -n "$$(./vendor/frostfs-adm -c frostfs-adm.yml morph frostfsid list-subjects --namespace '')" ]; then \
|
|
|
|
echo "Subject already exists"; \
|
|
|
|
else \
|
|
|
|
subj_key=`docker container exec -it morph_chain neo-go wallet dump-keys -w /wallets/wallet.json | tail -1 | tr -d ' \r\n'` \
|
2024-08-08 10:18:13 +00:00
|
|
|
&& echo "Subject key: $${subj_key}" \
|
|
|
|
&& ./vendor/frostfs-adm -c frostfs-adm.yml morph frostfsid create-subject --namespace "" --subject-key $${subj_key} --subject-name walletsubject \
|
|
|
|
|| die "Failed to create subject for the wallet"; \
|
2024-08-17 05:08:24 +00:00
|
|
|
fi
|
2024-08-08 10:18:13 +00:00
|
|
|
echo "FrostFS sidechain environment is deployed"
|
2022-09-08 15:04:44 +00:00
|
|
|
|
2022-02-04 15:27:49 +00:00
|
|
|
# Build up certain service
|
|
|
|
.PHONY: up/%
|
|
|
|
up/%: get vendor/hosts
|
|
|
|
@docker-compose -f services/$*/docker-compose.yml up -d
|
|
|
|
@echo "Developer Environment for $* service 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
|
2022-09-09 14:39:24 +00:00
|
|
|
down: down/add down/basic down/bootstrap
|
2022-12-21 12:34:14 +00:00
|
|
|
@echo "Full FrostFS Developer Environment is down"
|
2022-02-04 15:27:49 +00:00
|
|
|
|
|
|
|
.PHONY: down/add
|
|
|
|
down/add:
|
2020-07-10 15:14:30 +00:00
|
|
|
$(foreach SVC, $(STOP_SVCS), $(shell docker-compose -f services/$(SVC)/docker-compose.yml down))
|
|
|
|
|
2022-02-04 15:27:49 +00:00
|
|
|
# Stop basic environment
|
|
|
|
.PHONY: down/basic
|
|
|
|
down/basic:
|
|
|
|
$(foreach SVC, $(STOP_BASIC), $(shell docker-compose -f services/$(SVC)/docker-compose.yml down))
|
|
|
|
|
2022-09-09 14:39:24 +00:00
|
|
|
# Stop bootstrap services
|
|
|
|
.PHONY: down/bootstrap
|
|
|
|
down/bootstrap:
|
|
|
|
$(foreach SVC, $(STOP_BOOTSTRAP), $(shell docker-compose -f services/$(SVC)/docker-compose.yml down))
|
2022-09-08 15:04:44 +00:00
|
|
|
|
2022-02-04 15:27:49 +00:00
|
|
|
# Stop certain service
|
|
|
|
.PHONY: down/%
|
|
|
|
down/%:
|
|
|
|
@docker-compose -f services/$*/docker-compose.yml down
|
|
|
|
|
2022-10-12 14:04:37 +00:00
|
|
|
# Generate changes for /etc/hosts
|
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 > $@
|
|
|
|
|
2022-10-12 14:04:37 +00:00
|
|
|
# Generate and display changes for /etc/hosts
|
2020-09-24 09:34:19 +00:00
|
|
|
.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:
|
2024-10-31 07:24:30 +00:00
|
|
|
@rm -rf vendor/* services/storage/s04tls.*
|
2022-04-07 12:33:53 +00:00
|
|
|
@> .int_test.env
|
|
|
|
@for svc in $(PULL_SVCS)
|
2021-01-13 10:28:19 +00:00
|
|
|
do
|
|
|
|
vols=`docker-compose -f services/$${svc}/docker-compose.yml config --volumes`
|
|
|
|
if [[ ! -z "$${vols}" ]]; then
|
|
|
|
for vol in $${vols}; do
|
2022-09-12 15:42:50 +00:00
|
|
|
docker volume rm -f "$${svc}_$${vol}" 2> /dev/null
|
2021-01-13 10:28:19 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
2021-04-29 14:34:23 +00:00
|
|
|
|
|
|
|
# Generate environment
|
|
|
|
.PHONY: env
|
|
|
|
env:
|
|
|
|
@$(foreach envvar,$(GREP_DOTENV),echo $(envvar);)
|
2023-05-03 08:56:23 +00:00
|
|
|
@echo MORPH_BLOCK_TIME=$(shell grep 'TimePerBlock' $(MORPH_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
|
|
|
|
|