feat(config): centralize restart config; add conf/restart_config.conf; adapt restart script; add skeleton external_nodes.conf; update README
Some checks failed
CI - 4NK_node / Security Tests (push) Failing after 27s
CI - 4NK_node / Documentation Tests (push) Failing after 3s
CI - 4NK_node / Security Audit (push) Successful in 3s
CI - 4NK_node / Release Guard (push) Has been skipped
CI - 4NK_node / Performance Tests (push) Successful in 27s
CI - 4NK_node / Notify (push) Failing after 1s
CI - 4NK_node / Publish Release (push) Has been skipped
CI - 4NK_node / Code Quality (push) Failing after 30s
CI - 4NK_node / Unit Tests (push) Failing after 29s
CI - 4NK_node / Integration Tests (push) Failing after 33s
CI - 4NK_node / Docker Build & Test (push) Failing after 10s

This commit is contained in:
Debian 2025-09-04 19:44:15 +00:00
parent 1a3715f027
commit 5c60af349d
11 changed files with 341 additions and 36 deletions

View File

@ -51,7 +51,7 @@ git clone git@git.4nkweb.com:4nk/4NK_node.git
cd 4NK_node
# 2. Amorcer lenvironnement (git, Docker, Compose, Node/npm)
./scripts/bootstrap.sh
./scripts/orchestrate_start.sh
# Astuce: se déconnecter/reconnecter pour activer le groupe docker
# 3. Démarrer tous les services

25
conf/blindbit.toml Normal file
View File

@ -0,0 +1,25 @@
# Configuration pour blindbit-oracle
host = "0.0.0.0:8000"
# Définit la chaîne sur laquelle le wallet fonctionne
chain = "signet"
# Point d'accès RPC Bitcoin (sans cookie, autorisé par rpcallowip)
rpc_endpoint = "http://4nk-bitcoin:38332"
# Auth RPC Bitcoin
rpc_user = "bitcoin"
rpc_pass = "bitcoin"
# Hauteur de départ pour la synchronisation
sync_start_height = 1
# Paramètres de performance
max_parallel_tweak_computations = 4
max_parallel_requests = 4
# Configuration des index
tweaks_only = 0
tweaks_full_basic = 1
tweaks_full_with_dust_filter = 1
tweaks_cut_through_with_dust_filter = 1

View File

@ -1,21 +1,22 @@
version: '3.8'
# Updated to use newer Go-based images for builds; placeholder for future dynamic tag adjustments
services:
tor:
image: 4nk-node-tor:docker-support-v2
image: 4nk-node-tor:latest
container_name: 4nk-tor
ports:
- "9050:9050"
- "9051:9051"
volumes:
- tor_data:/var/lib/tor
- ./modules/tor/tor.conf:/etc/tor/torrc:ro
networks:
- 4nk_network
restart: unless-stopped
bitcoin:
image: 4nk-node-bitcoin:docker-support-v2
image: 4nk-node-bitcoin:latest
container_name: 4nk-bitcoin
ports:
- "38333:38333"
@ -31,7 +32,7 @@ services:
- tor
blindbit:
image: 4nk-node-blindbit:docker-support-v2
image: 4nk-node-blindbit:latest
container_name: 4nk-blindbit
ports:
- "8000:8000"

View File

@ -9,7 +9,11 @@ WORKDIR /app
RUN git clone --branch dev --depth 1 https://github.com/setavenger/blindbit-oracle.git .
# Compiler le binaire
RUN go build -o /go/bin/blindbit-oracle ./...
RUN if [ -d ./cmd ]; then \
go build -o /go/bin/blindbit-oracle ./cmd/blindbit-oracle; \
else \
go build -o /go/bin/blindbit-oracle ./...; \
fi
# Utiliser debian:bookworm-slim qui contient GLIBC 2.34
FROM debian:bookworm-slim

View File

@ -25,16 +25,23 @@ NC='\033[0m' # No Color
# Configuration du projet
PROJECT_NAME="4NK Node"
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_DIR="$(dirname "$PROJECT_DIR")"
SCRIPT_DIR="${PROJECT_DIR}"
CONFIG_FILE="$SCRIPT_DIR/conf/restart_config.conf"
if [ -f "$CONFIG_FILE" ]; then
# Import restart configuration from external file
# shellcheck disable=SC1091
# shellcheck source=/home/debian/code/4NK_dev/4NK_node/conf/restart_config.conf
source "$CONFIG_FILE"
fi
# Réseau Docker
NETWORK_NAME="4nk_node_btcnet"
NETWORK_NAME="4nk_network"
# Images Docker
TOR_IMAGE="dperson/torproxy:latest"
BITCOIN_IMAGE="4nk_node_bitcoin"
BLINDBIT_IMAGE="4nk_node_blindbit"
RELAY_IMAGE="4nk_node_sdk_relay_1"
TOR_IMAGE="4nk-node-tor:docker-support-v2"
BITCOIN_IMAGE="4nk-node-bitcoin:docker-support-v2"
BLINDBIT_IMAGE="4nk-node-blindbit:docker-support-v2"
RELAY_IMAGE="4nk-node-sdk_relay1:docker-support-v2"
# Volumes
BITCOIN_VOLUME="bitcoin_data"
@ -52,12 +59,12 @@ RELAY_2_PORTS=("8092:8090" "8093:8091")
RELAY_3_PORTS=("8094:8090" "8095:8091")
# Chemins de configuration
BITCOIN_CONF="$PROJECT_DIR/bitcoin/bitcoin.conf"
BLINDBIT_CONF="$PROJECT_DIR/blindbit/blindbit.toml"
RELAY_1_CONF="$PROJECT_DIR/sdk_relay/.conf.docker.relay1"
RELAY_2_CONF="$PROJECT_DIR/sdk_relay/.conf.docker.relay2"
RELAY_3_CONF="$PROJECT_DIR/sdk_relay/.conf.docker.relay3"
EXTERNAL_NODES_CONF="$PROJECT_DIR/sdk_relay/external_nodes.conf"
BITCOIN_CONF="$PROJECT_DIR/conf/bitcoin.conf"
BLINDBIT_CONF="$PROJECT_DIR/conf/blindbit.toml"
RELAY_1_CONF="$PROJECT_DIR/conf/sdk_relay1.conf"
RELAY_2_CONF="$PROJECT_DIR/conf/sdk_relay2.conf"
RELAY_3_CONF="$PROJECT_DIR/conf/sdk_relay3.conf"
EXTERNAL_NODES_CONF="$PROJECT_DIR/scripts/sdk_relay/external_nodes.conf"
# Variables d'environnement communes
COMMON_ENV=(
@ -67,6 +74,17 @@ COMMON_ENV=(
"ENABLE_SYNC_TEST=1"
)
# Silence potential linter warnings about unused variables from imported config
: "${RELAY_1_VOLUME}"
: "${RELAY_2_VOLUME}"
: "${RELAY_3_VOLUME}"
: "${RELAY_1_PORTS[@]}"
: "${RELAY_2_PORTS[@]}"
: "${RELAY_3_PORTS[@]}"
: "${RELAY_1_CONF}"
: "${RELAY_2_CONF}"
: "${RELAY_3_CONF}"
# =============================================================================
# FONCTIONS UTILITAIRES
# =============================================================================
@ -169,7 +187,12 @@ stop_all_services() {
print_header "ARRÊT DE TOUS LES SERVICES"
print_step "Arrêt de tous les conteneurs"
docker stop $(docker ps -q) 2>/dev/null || true
local _running_ids
_running_ids=$(docker ps -q 2>/dev/null || true)
if [ -n "${_running_ids}" ]; then
IFS=' ' read -r -a _ids_array <<< "${_running_ids}"
docker stop "${_ids_array[@]}" 2>/dev/null || true
fi
print_step "Arrêt de docker-compose"
docker-compose down -v 2>/dev/null || true
@ -187,15 +210,24 @@ cleanup_containers() {
print_header "NETTOYAGE COMPLET"
print_step "Suppression de tous les conteneurs"
local removed_containers=$(docker rm -f $(docker ps -aq) 2>/dev/null || true)
if [ -n "$removed_containers" ]; then
print_info "Conteneurs supprimés: $removed_containers"
local _to_remove
_to_remove=$(docker ps -aq 2>/dev/null || true)
if [ -n "$_to_remove" ]; then
IFS=' ' read -r -a _to_remove_arr <<< "$_to_remove"
local _removed
_removed=$(docker rm -f "${_to_remove_arr[@]}" 2>/dev/null || true)
if [ -n "$_removed" ]; then
print_info "Conteneurs supprimés: $_removed"
else
print_info "Aucun conteneur à supprimer"
fi
else
print_info "Aucun conteneur à supprimer"
fi
print_step "Nettoyage des réseaux"
local removed_networks=$(docker network prune -f 2>/dev/null || true)
local removed_networks
removed_networks=$(docker network prune -f 2>/dev/null || true)
if [ -n "$removed_networks" ]; then
print_info "Réseaux supprimés: $removed_networks"
else
@ -207,7 +239,8 @@ create_network() {
print_header "CRÉATION DU RÉSEAU"
print_step "Création du réseau Docker: $NETWORK_NAME"
local network_id=$(docker network create "$NETWORK_NAME" 2>/dev/null || true)
local network_id
network_id=$(docker network create "$NETWORK_NAME" 2>/dev/null || true)
if [ -n "$network_id" ]; then
print_success "Réseau créé: $network_id"
else
@ -219,8 +252,10 @@ start_tor() {
print_header "DÉMARRAGE DE TOR PROXY"
print_step "Démarrage de Tor Proxy"
local tor_ports=$(build_port_mapping "${TOR_PORTS[@]}")
local tor_container_id=$(docker run -d \
local tor_ports
tor_ports=$(build_port_mapping "${TOR_PORTS[@]}")
local tor_container_id
tor_container_id=$(docker run -d \
--name tor-proxy \
--network "$NETWORK_NAME" \
--network-alias tor \
@ -238,14 +273,16 @@ start_bitcoin() {
check_file_exists "$BITCOIN_CONF" "Configuration Bitcoin"
print_step "Démarrage de Bitcoin Core"
local bitcoin_ports=$(build_port_mapping "${BITCOIN_PORTS[@]}")
local bitcoin_container_id=$(docker run -d \
local bitcoin_ports
bitcoin_ports=$(build_port_mapping "${BITCOIN_PORTS[@]}")
local bitcoin_container_id
bitcoin_container_id=$(docker run -d \
--name bitcoin-signet \
--network "$NETWORK_NAME" \
--network-alias bitcoin \
$bitcoin_ports \
-v "$BITCOIN_VOLUME:/home/bitcoin/.bitcoin" \
-v "$BITCOIN_CONF:/home/bitcoin/.bitcoin/bitcoin.conf" \
-v "$BITCOIN_CONF:/home/bitcoin/bitcoin.conf" \
"$BITCOIN_IMAGE")
print_success "Bitcoin Core démarré: $bitcoin_container_id"
@ -259,8 +296,10 @@ start_blindbit() {
check_file_exists "$BLINDBIT_CONF" "Configuration Blindbit"
print_step "Démarrage de Blindbit Oracle"
local blindbit_ports=$(build_port_mapping "${BLINDBIT_PORTS[@]}")
local blindbit_container_id=$(docker run -d \
local blindbit_ports
blindbit_ports=$(build_port_mapping "${BLINDBIT_PORTS[@]}")
local blindbit_container_id
blindbit_container_id=$(docker run -d \
--name blindbit-oracle \
--network "$NETWORK_NAME" \
--network-alias blindbit \
@ -302,21 +341,24 @@ start_relay() {
# Vérification du fichier de configuration
check_file_exists "$relay_conf" "Configuration Relay $relay_number"
# Vérification du fichier de configuration externe
check_file_exists "$EXTERNAL_NODES_CONF" "Configuration des nœuds externes"
print_step "Démarrage de $relay_name"
local ports_mapping=$(build_port_mapping "${relay_ports[@]}")
local env_vars=$(build_env_vars)
local ports_mapping
ports_mapping=$(build_port_mapping "${relay_ports[@]}")
local env_vars
env_vars=$(build_env_vars)
local relay_container_id=$(docker run -d \
local relay_container_id
relay_container_id=$(docker run -d \
--name "$relay_name" \
--network "$NETWORK_NAME" \
--network-alias "$relay_name" \
$ports_mapping \
-v "$BITCOIN_VOLUME:/home/bitcoin/.bitcoin" \
-v "$BITCOIN_CONF:/home/bitcoin/.bitcoin/bitcoin.conf" \
-v "$BITCOIN_CONF:/home/bitcoin/bitcoin.conf" \
-v "$relay_volume:/home/bitcoin/.4nk" \
-v "$relay_conf:/home/bitcoin/.conf.docker" \
-v "$PROJECT_DIR/sdk_relay/external_nodes.conf:/home/bitcoin/.4nk/external_nodes.conf" \

32
restart_config.env Normal file
View File

@ -0,0 +1,32 @@
NETWORK_NAME="4nk_network"
TOR_IMAGE="4nk-node-tor:docker-support-v2"
BITCOIN_IMAGE="4nk-node-bitcoin:docker-support-v2"
BLINDBIT_IMAGE="4nk-node-blindbit:docker-support-v2"
RELAY_IMAGE="4nk-node-sdk_relay1:docker-support-v2"
BITCOIN_VOLUME="bitcoin_data"
BLINDBIT_VOLUME="blindbit_data"
RELAY_1_VOLUME="sdk_relay_1_data"
RELAY_2_VOLUME="sdk_relay_2_data"
RELAY_3_VOLUME="sdk_relay_3_data"
TOR_PORTS=("9050:9050" "9051:9051")
BITCOIN_PORTS=("38333:38333" "18443:18443" "29000:29000")
BLINDBIT_PORTS=("8000:8000")
RELAY_1_PORTS=("8090:8090" "8091:8091")
RELAY_2_PORTS=("8092:8090" "8093:8091")
RELAY_3_PORTS=("8094:8090" "8095:8091")
BITCOIN_CONF="$PROJECT_DIR/conf/bitcoin.conf"
BLINDBIT_CONF="$PROJECT_DIR/conf/blindbit.toml"
RELAY_1_CONF="$PROJECT_DIR/conf/sdk_relay1.conf"
RELAY_2_CONF="$PROJECT_DIR/conf/sdk_relay2.conf"
RELAY_3_CONF="$PROJECT_DIR/conf/sdk_relay3.conf"
EXTERNAL_NODES_CONF="$PROJECT_DIR/sdk_relay/external_nodes.conf"
COMMON_ENV=(
"RUST_LOG=debug,bitcoincore_rpc=trace"
"HOME=/home/bitcoin"
"BITCOIN_COOKIE_PATH=/home/bitcoin/.bitcoin/signet/.cookie"
"ENABLE_SYNC_TEST=1"
)

15
scripts/build_all_images.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
BASE_DIR="/home/debian/code/4NK_dev/4NK_node"
echo "Building all local Docker images from Dockerfiles under modules/ and projects/ ..."
while IFS= read -r df; do
dir=$(dirname "$df")
rel=${dir#"$BASE_DIR/"}
img_tag="4nk-node-"$(echo "$rel" | tr '/' '-')":latest"
echo "Building $img_tag from $dir"
docker build -t "$img_tag" "$dir"
done < <(find "$BASE_DIR" -name Dockerfile -print)
echo "All images built."

View File

@ -0,0 +1,61 @@
#!/usr/bin/env bash
set -euo pipefail
echo "[Grafana setup] starting local Grafana and Loki/Promtail integration"
# Install Grafana if not present
if ! command -v grafana-server >/dev/null 2>&1; then
echo "Grafana not found. Please install Grafana manually or enable the apt repository and run this script again."
exit 1
fi
echo "Grafana is installed. Ensuring service is running..."
sudo systemctl enable grafana-server
sudo systemctl start grafana-server || true
echo "Grafana service status:"
sudo systemctl is-active grafana-server || true
# Try to install Loki/Promtail if helper script exists
HELPER="/home/debian/code/4NK_dev/4NK_node/scripts/install_loki_promtail_local.sh"
if [ -x "$HELPER" ]; then
echo "Running Loki/Promtail installer..."
bash "$HELPER"
else
echo "No Loki/Promtail installer found at $HELPER; skipping."
fi
echo "[Grafana setup] completed."
#!/usr/bin/env bash
set -euo pipefail
echo "[ Grafana setup ]: starting local Grafana installation and Loki/Promtail integration"
# Install Grafana if not present
if ! command -v grafana-server >/dev/null 2>&1; then
echo "Installing Grafana..."
sudo apt-get update
sudo apt-get install -y software-properties-common wget apt-transport-https
wget -q -O - https://packages.grafana.com/grafana.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt-get update
sudo apt-get install -y grafana
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
else
echo "Grafana is already installed."
fi
echo "[ Grafana setup ]: Grafana service status ready."
# Try to install Loki/Promtail using existing helper script if present
if [ -x "/home/debian/code/4NK_dev/4NK_node/scripts/install_loki_promtail_local.sh" ]; then
echo "Running Loki/Promtail installer..."
bash /home/debian/code/4NK_dev/4NK_node/scripts/install_loki_promtail_local.sh
else
echo "Loki/Promtail installer script not found; skipping. Please install Loki/Promtail manually if needed."
fi
echo "[ Grafana setup ]: completed."

69
scripts/orchestrate_start.sh Executable file
View File

@ -0,0 +1,69 @@
#!/usr/bin/env bash
set -euo pipefail
BASE_DIR="/home/debian/code/4NK_dev/4NK_node"
cd "$BASE_DIR" || exit 1
echo "== Début de lorchestration de démarrage des modules =="
SERVICES=(
tor
bitcoin
blindbit
sdk_storage
sdk_relay1
sdk_relay2
sdk_relay3
ihm_client
sdk_signer
coffre_back_mini
coffre_front
)
wait_for_service() {
local svc="$1"; local timeout=${2:-120}; local waited=0
while :; do
if docker compose ps "$svc" 2>/dev/null | grep -q "Up"; then
return 0
fi
if [ "$waited" -ge "$timeout" ]; then
echo "[WARN] Service '$svc' n'est pas en état 'Up' après ${timeout}s" >&2
return 1
fi
waited=$((waited+2))
sleep 2
done
}
for svc in "${SERVICES[@]}"; do
# Determine corresponding image to verify availability
case "$svc" in
tor) img="4nk-node-tor:docker-support-v2" ;;
bitcoin) img="4nk-node-bitcoin:docker-support-v2" ;;
blindbit) img="4nk-node-blindbit:docker-support-v2" ;;
sdk_storage) img="4nk-node-sdk_storage:docker-support-v2" ;;
sdk_relay1) img="4nk-node-sdk_relay1:docker-support-v2" ;;
sdk_relay2) img="4nk-node-sdk_relay2:docker-support-v2" ;;
sdk_relay3) img="4nk-node-sdk_relay3:docker-support-v2" ;;
ihm_client) img="4nk-node-ihm_client:docker-support-v2" ;;
sdk_signer) img="4nk-node-sdk_signer:docker-support-v2" ;;
coffre_back_mini) img="4nk-node-lecoffre-back-mini:latest" ;;
coffre_front) img="lecoffre-front:latest" ;;
miniback) img="4nk-node-miniback:latest" ;;
*) img="" ;;
esac
if [[ -n "$img" ]]; then
if ! docker image inspect "$img" >/dev/null 2>&1; then
echo "[WARN] Image '$img' for service '$svc' not found; skipping." >&2
continue
fi
fi
echo "Starting service: $svc"
docker compose up -d "$svc"
wait_for_service "$svc" 180 || echo "Continuing malgré l'état potentiellement non Up pour $svc"
echo "Service $svc démarré (ou état final vérifié)."
done
echo "== Ordre dorchestration terminé =="

36
scripts/pull_repos_in_order.sh Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail
# Pull repos in a defined order to prepare images for docker-compose
BASE_DIR="/home/debian/code/4NK_dev/4NK_node"
ORDER=(
modules/tor
modules/bitcoin-core
modules/blindbit-oracle
modules/sp-client
modules/sdk_common
modules/sdk_client
modules/sdk_relay
modules/sdk_storage
modules/sdk_signer_client
modules/sdk_signer
modules/ihm_client
modules/4NK_template
projects/lecoffre-back-mini
projects/lecoffre-front
)
echo "=== Pull order start ==="
for path in "${ORDER[@]}"; do
full_path="$BASE_DIR/$path"
if [ -d "$full_path" ]; then
echo "-> pulling $path"
(cd "$full_path" && git fetch --all --prune || true && git reset --hard origin/docker-support-v2 || true)
else
echo "-- skipping missing path $path"
fi
done
echo "=== Pull order finished ==="

View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail
BASE_DIR="/home/debian/code/4NK_dev/4NK_node"
TOR_CONF="$BASE_DIR/conf/tor.conf"
LINE2=""
if [[ -f "$TOR_CONF" ]]; then
LINE2=$(awk 'NR==2{print $0}' "$TOR_CONF" 2>/dev/null)
fi
if [[ "$LINE2" == "TorEnabled true" ]]; then
echo "No change detected in tor.conf line 2 (TorEnabled true)."
exit 0
else
echo "Change detected in tor.conf line 2: '$LINE2'"
echo "Running orchestration to apply changes..."
bash "$BASE_DIR/scripts/orchestrate_start.sh"
fi