-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#385] Integrate prepare-config script functionality into Makefile sy…
…stem This commit eliminates the prepare-config.sh script, incorporating its configuration preparation logic into the Makefile workflow with a new config.mk file. This adjustment enhances the consistency of the deployment process, aligning it with the modular Makefile approach. It simplifies the management of configurations by dynamically generating necessary files from templates, thereby improving the security and maintainability of configuration secrets. Adjustments to related Makefiles files have been made to accommodate these changes, streamlining the entire configuration and deployment pipeline.
- Loading branch information
Showing
18 changed files
with
118 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
common_mk := ../../scripts/govtool/common.mk | ||
ifeq ($(origin $(common_mk)), undefined) | ||
$(eval $(common_mk) := included) | ||
include $(common_mk) | ||
endif | ||
|
||
# directory paths | ||
config_dir := $(root_dir)/scripts/govtool/config | ||
target_config_dir := $(config_dir)/target | ||
template_config_dir := $(config_dir)/templates | ||
cardano_node_config_dir := $(target_config_dir)/cardano-node | ||
dbsync_secrets_dir := $(target_config_dir)/dbsync-secrets | ||
grafana_provisioning_dir := $(target_config_dir)/grafana-provisioning | ||
nginx_config_dir := $(target_config_dir)/nginx | ||
|
||
# metadata | ||
cardano_config_provider := https://book.world.dev.cardano.org | ||
|
||
.PHONY: prepare-config | ||
prepare-config: clear enable-prometheus prepare-dbsync-secrets prepare-backend-config prepare-prometheus-config prepare-grafana-provisioning prepare-nginx-config | ||
|
||
.PHONY: clear | ||
clear: | ||
rm -rf $(target_config_dir) | ||
|
||
.PHONY: fetch-cardano-node-config | ||
fetch-cardano-node-config: | ||
@:$(call check_defined, cardano_network) | ||
mkdir -p $(cardano_node_config_dir) | ||
$(curl) -s "$(cardano_config_provider)/env-$(cardano_network).html" | \ | ||
grep -E -o '[a-z-]+\.json' | \ | ||
sort -u | \ | ||
xargs -I"{}" $(curl) -s "$(cardano_config_provider)/environments/$(cardano_network)/{}" -o "$(cardano_node_config_dir)/{}" | ||
|
||
.PHONY: enable-prometheus | ||
enable-prometheus: fetch-cardano-node-config | ||
sed -i '/"hasPrometheus"/ { N; s/"127\.0\.0\.1"/"0.0.0.0"/ }' "$(cardano_node_config_dir)/config.json" | ||
|
||
.PHONY: prepare-dbsync-secrets | ||
prepare-dbsync-secrets: | ||
mkdir -p $(dbsync_secrets_dir) | ||
echo "$${DBSYNC_POSTGRES_USER}" > "$(dbsync_secrets_dir)/postgres_user"; \ | ||
echo "$${DBSYNC_POSTGRES_PASSWORD}" > "$(dbsync_secrets_dir)/postgres_password"; \ | ||
echo "$${DBSYNC_POSTGRES_DB}" > "$(dbsync_secrets_dir)/postgres_db" | ||
|
||
.PHONY: prepare-backend-config | ||
prepare-backend-config: | ||
sed -e "s/DBSYNC_POSTGRES_DB/$${DBSYNC_POSTGRES_DB}/" \ | ||
-e "s/DBSYNC_POSTGRES_USER/$${DBSYNC_POSTGRES_USER}/" \ | ||
-e "s/DBSYNC_POSTGRES_PASSWORD/$${DBSYNC_POSTGRES_PASSWORD}/" \ | ||
-e "s|SENTRY_DSN|$${SENTRY_DSN_BACKEND}|" \ | ||
"$(config_dir)/templates/backend-config.json.tpl" \ | ||
> "$(target_config_dir)/backend-config.json" | ||
|
||
.PHONY: prepare-prometheus-config | ||
prepare-prometheus-config: | ||
cp -a "$(template_config_dir)/prometheus.yml" "$(target_config_dir)/prometheus.yml" | ||
|
||
PHONY: prepare-grafana-provisioning | ||
prepare-grafana-provisioning: | ||
mkdir -p $(grafana_provisioning_dir) | ||
cp -a $(template_config_dir)/grafana-provisioning/* $(grafana_provisioning_dir) | ||
sed -e "s/GRAFANA_SLACK_RECIPIENT/$${GRAFANA_SLACK_RECIPIENT}/" \ | ||
-e "s|GRAFANA_SLACK_OAUTH_TOKEN|$${GRAFANA_SLACK_OAUTH_TOKEN}|" \ | ||
-i $(grafana_provisioning_dir)/alerting/alerting.yml | ||
|
||
.PHONY: prepare-nginx-config | ||
prepare-nginx-config: | ||
@:$(call check_defined, domain) | ||
mkdir -p $(nginx_config_dir) | ||
touch "$(nginx_config_dir)/auth.conf" | ||
touch "$(nginx_config_dir)/govtool.htpasswd" | ||
if [[ "$(domain)" == *"sanchonet.govtool.byron.network"* ]]; then \ | ||
echo "$${NGINX_BASIC_AUTH}" > "$(nginx_config_dir)/govtool.htpasswd"; \ | ||
echo "auth_basic \"Restricted\";" > "$(nginx_config_dir)/auth.conf"; \ | ||
echo "auth_basic_user_file /etc/nginx/conf.d/govtool.htpasswd;" >> "$(nginx_config_dir)/auth.conf"; \ | ||
fi | ||
|
||
.PHONY: upload-config | ||
upload-config: check-env-defined prepare-config | ||
@:$(call check_defined, ssh_url) | ||
$(rsync) -av -e 'ssh -o StrictHostKeyChecking=no' config/target/. $(ssh_url):config |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
global: | ||
scrape_interval: 15s | ||
evaluation_interval: 15s | ||
external_labels: | ||
monitor: 'govtool' | ||
scrape_configs: | ||
- job_name: 'traefik' | ||
scrape_interval: 5s | ||
static_configs: | ||
- targets: ['traefik:8082'] | ||
- job_name: 'cardano' | ||
scrape_interval: 5s | ||
static_configs: | ||
- targets: ['cardano-node:12798'] | ||
- job_name: 'cardano_db_sync' | ||
scrape_interval: 5s | ||
metrics_path: / | ||
static_configs: | ||
- targets: ['cardano-db-sync:8080'] | ||
- job_name: 'host' | ||
scrape_interval: 5s | ||
static_configs: | ||
- targets: ['host.docker.internal:9100'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters