Add status-init docker util

This commit is contained in:
Alberto Soutullo
2025-06-27 18:10:09 +02:00
parent b9e1b3b0d7
commit 7eb5b94135
4 changed files with 107 additions and 0 deletions

13
docker-utils/README.md Normal file
View File

@@ -0,0 +1,13 @@
# Docker-utils
Containers that will be needed for the experiments.
## status-init
This container is in charge of preparing `/static/configs/config.json` file for `status-backend`.
It will grab the ENR of the store nodes that will also act as bootstrap, and put it in the json file.
## status-subscriber
Simple container that will connect to `status-backend` signal to log information.

View File

@@ -0,0 +1,22 @@
FROM python:3.11-slim
# Install required packages
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
gnupg \
apt-transport-https
# Download kubectl
RUN curl -LO "https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# Make it executable and move to path
RUN chmod +x kubectl && mv kubectl /usr/local/bin/
# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install Python dependencies
RUN pip install websockets requests kubernetes rlp multihash base58 eth-enr eth-keys
COPY init_container.py /init_container.py

View File

@@ -0,0 +1,9 @@
# status-init
This container is in charge of preparing `/static/configs/config.json` file for `status-backend`.
It will grab the env variables of BOOT_ENRS and STORE_ENRS (bootstrap and store nodes) and put them it in the configuration.
## Changelog
- v1.0.0
- Working with status-backend `b22c58bd3bdd4a387dc09dccba1d866d5ae09adf`

View File

@@ -0,0 +1,63 @@
import json
import os
import sys
import logging
from pathlib import Path
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def update_config():
bootstrap_enrs = [
os.getenv(env)
for env in os.environ
if env.startswith("BOOT_ENRS") and os.getenv(env).startswith("enr:")
]
store_enrs = [
os.getenv(env)
for env in os.environ
if env.startswith("STORE_ENRS") and os.getenv(env).startswith("enr:")
]
config_path = os.getenv("CONFIG_PATH", "/static/configs/config.json")
try:
config_dir = Path(config_path).parent
config_dir.mkdir(parents=True, exist_ok=True)
logger.info(f"Ensured config folder exists at: {config_dir}")
config = {
"dst.dev": {
"wakuNodes": bootstrap_enrs,
"discV5BootstrapNodes": [],
"clusterId": int(os.getenv("CLUSTER_ID", 16)),
"storeNodes": []
}
}
for counter, enr in enumerate(store_enrs):
config["dst.dev"]["storeNodes"].append({
"id": f"store-node-{counter}",
"enr": enr,
"addr": "",
"fleet": "dst.dev"
})
with open(config_path, "w") as f:
json.dump(config, f, indent=2)
logger.info(f"Configuration successfully written to {config_path}")
except Exception as e:
logger.error(f"Failed to update config: {e}", exc_info=True)
sys.exit(1)
def main():
update_config()
if __name__ == "__main__":
main()