forked from cerc-io/stack-orchestrator
Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e856616be8 | ||
|
|
2da03d7ed1 | ||
|
|
6a0a752e2e | ||
|
|
5afe7a29ae | ||
|
|
a8f4e4cee4 | ||
|
|
45ba1f337f | ||
|
|
0feeab6418 | ||
|
|
4ee745a4db | ||
|
|
8eed5a70a5 | ||
|
|
758ec168bd | ||
|
|
63a94bae0e | ||
|
|
29fc611885 | ||
|
|
1f9131ff5a | ||
|
|
950857fa84 | ||
|
|
54f50aa09e | ||
|
|
a5945c9e59 | ||
|
|
c8b4f89335 |
@@ -12,7 +12,7 @@ jobs:
|
||||
- name: "Clone project repository"
|
||||
uses: actions/checkout@v3
|
||||
- name: "Install Python"
|
||||
uses: cerc-io/setup-python@v4
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- name: "Print Python version"
|
||||
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
build_tag=$(./scripts/create_build_tag_file.sh)
|
||||
echo "build-tag=v${build_tag}" >> $GITHUB_OUTPUT
|
||||
- name: "Install Python"
|
||||
uses: cerc-io/setup-python@v4
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- name: "Print Python version"
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
run: |
|
||||
cp ${{ steps.build.outputs.package-file }} ./laconic-so
|
||||
- name: "Create release"
|
||||
uses: cerc-io/action-gh-release@gitea-v1
|
||||
uses: https://gitea.com/cerc-io/action-gh-release@gitea-v2
|
||||
with:
|
||||
tag_name: ${{ steps.build-info.outputs.build-tag }}
|
||||
# On the publish test branch, mark our release as a draft
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
- name: "Clone project repository"
|
||||
uses: actions/checkout@v3
|
||||
- name: "Install Python"
|
||||
uses: cerc-io/setup-python@v4
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- name: "Print Python version"
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
- name: "Clone project repository"
|
||||
uses: actions/checkout@v3
|
||||
- name: "Install Python"
|
||||
uses: cerc-io/setup-python@v4
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- name: "Print Python version"
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
|
||||
import os
|
||||
from abc import ABC, abstractmethod
|
||||
from .deploy import get_stack_status
|
||||
from app.deploy import get_stack_status
|
||||
from decouple import config
|
||||
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ import subprocess
|
||||
import click
|
||||
import importlib.resources
|
||||
from pathlib import Path
|
||||
from .util import include_exclude_check, get_parsed_stack_config
|
||||
from .base import get_npm_registry_url
|
||||
from app.util import include_exclude_check, get_parsed_stack_config
|
||||
from app.base import get_npm_registry_url
|
||||
|
||||
# TODO: find a place for this
|
||||
# epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)"
|
||||
@@ -67,7 +67,7 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
||||
print('Dev root directory doesn\'t exist, creating')
|
||||
|
||||
# See: https://stackoverflow.com/a/20885799/1701505
|
||||
from . import data
|
||||
from app import data
|
||||
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
||||
all_containers = container_list_file.read().splitlines()
|
||||
|
||||
|
||||
+3
-3
@@ -25,8 +25,8 @@ from decouple import config
|
||||
import click
|
||||
import importlib.resources
|
||||
from python_on_whales import docker, DockerException
|
||||
from .base import get_stack
|
||||
from .util import include_exclude_check, get_parsed_stack_config
|
||||
from app.base import get_stack
|
||||
from app.util import include_exclude_check, get_parsed_stack_config
|
||||
|
||||
builder_js_image_name = "cerc/builder-js:local"
|
||||
|
||||
@@ -81,7 +81,7 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
||||
os.makedirs(build_root_path)
|
||||
|
||||
# See: https://stackoverflow.com/a/20885799/1701505
|
||||
from . import data
|
||||
from app import data
|
||||
with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file:
|
||||
all_packages = package_list_file.read().splitlines()
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ services:
|
||||
command: |
|
||||
"./wait-for-it.sh -h ${CERC_L1_HOST:-$${DEFAULT_CERC_L1_HOST}} -p ${CERC_L1_PORT:-$${DEFAULT_CERC_L1_PORT}} -s -t 60 -- ./run.sh"
|
||||
volumes:
|
||||
- ../config/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh
|
||||
- ../container-build/cerc-optimism-contracts/hardhat-tasks/verify-contract-deployment.ts:/app/packages/contracts-bedrock/tasks/verify-contract-deployment.ts
|
||||
- ../container-build/cerc-optimism-contracts/hardhat-tasks/rekey-json.ts:/app/packages/contracts-bedrock/tasks/rekey-json.ts
|
||||
- ../container-build/cerc-optimism-contracts/hardhat-tasks/send-balance.ts:/app/packages/contracts-bedrock/tasks/send-balance.ts
|
||||
- ../config/network/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh
|
||||
- ../config/optimism-contracts/hardhat-tasks/verify-contract-deployment.ts:/app/packages/contracts-bedrock/tasks/verify-contract-deployment.ts
|
||||
- ../config/optimism-contracts/hardhat-tasks/rekey-json.ts:/app/packages/contracts-bedrock/tasks/rekey-json.ts
|
||||
- ../config/optimism-contracts/hardhat-tasks/send-balance.ts:/app/packages/contracts-bedrock/tasks/send-balance.ts
|
||||
- ../config/fixturenet-optimism/optimism-contracts/update-config.js:/app/packages/contracts-bedrock/update-config.js
|
||||
- ../config/fixturenet-optimism/optimism-contracts/run.sh:/app/packages/contracts-bedrock/run.sh
|
||||
- l2_accounts:/l2-accounts
|
||||
@@ -120,7 +120,7 @@ services:
|
||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||
CERC_L1_RPC: ${CERC_L1_RPC}
|
||||
volumes:
|
||||
- ../config/wait-for-it.sh:/wait-for-it.sh
|
||||
- ../config/network/wait-for-it.sh:/wait-for-it.sh
|
||||
- ../config/fixturenet-optimism/run-op-batcher.sh:/run-op-batcher.sh
|
||||
- l2_accounts:/l2-accounts:ro
|
||||
entrypoint: ["sh", "-c"]
|
||||
@@ -145,7 +145,7 @@ services:
|
||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||
CERC_L1_RPC: ${CERC_L1_RPC}
|
||||
volumes:
|
||||
- ../config/wait-for-it.sh:/wait-for-it.sh
|
||||
- ../config/network/wait-for-it.sh:/wait-for-it.sh
|
||||
- ../config/fixturenet-optimism/run-op-proposer.sh:/run-op-proposer.sh
|
||||
- l1_deployment:/contracts-bedrock:ro
|
||||
- l2_accounts:/l2-accounts:ro
|
||||
|
||||
@@ -9,7 +9,6 @@ services:
|
||||
image: cerc/fixturenet-plugeth-plugeth:local
|
||||
volumes:
|
||||
- fixturenet_plugeth_bootnode_geth_data:/root/ethdata
|
||||
- ../config/fixturenet-plugeth/plugins:/root/ethdata/plugins
|
||||
ports:
|
||||
- "9898"
|
||||
- "30303"
|
||||
@@ -66,7 +65,7 @@ services:
|
||||
hostname: fixturenet-eth-bootnode-lighthouse
|
||||
environment:
|
||||
RUN_BOOTNODE: "true"
|
||||
image: cerc/fixturenet-plugeth-lighthouse:local
|
||||
image: cerc/fixturenet-eth-lighthouse:local
|
||||
|
||||
fixturenet-eth-lighthouse-1:
|
||||
restart: always
|
||||
@@ -83,7 +82,7 @@ services:
|
||||
NODE_NUMBER: "1"
|
||||
ETH1_ENDPOINT: "http://fixturenet-eth-geth-1:8545"
|
||||
EXECUTION_ENDPOINT: "http://fixturenet-eth-geth-1:8551"
|
||||
image: cerc/fixturenet-plugeth-lighthouse:local
|
||||
image: cerc/fixturenet-eth-lighthouse:local
|
||||
volumes:
|
||||
- fixturenet_plugeth_lighthouse_1_data:/opt/testnet/build/cl
|
||||
depends_on:
|
||||
@@ -110,7 +109,7 @@ services:
|
||||
ETH1_ENDPOINT: "http://fixturenet-eth-geth-2:8545"
|
||||
EXECUTION_ENDPOINT: "http://fixturenet-eth-geth-2:8551"
|
||||
LIGHTHOUSE_GENESIS_STATE_URL: "http://fixturenet-eth-lighthouse-1:8001/eth/v2/debug/beacon/states/0"
|
||||
image: cerc/fixturenet-plugeth-lighthouse:local
|
||||
image: cerc/fixturenet-eth-lighthouse:local
|
||||
volumes:
|
||||
- fixturenet_plugeth_lighthouse_2_data:/opt/testnet/build/cl
|
||||
depends_on:
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
services:
|
||||
|
||||
mainnet-eth-geth-1:
|
||||
restart: always
|
||||
hostname: mainnet-eth-geth-1
|
||||
cap_add:
|
||||
- SYS_PTRACE
|
||||
environment:
|
||||
CERC_REMOTE_DEBUG: "true"
|
||||
CERC_RUN_STATEDIFF: ${CERC_RUN_STATEDIFF:-detect}
|
||||
CERC_STATEDIFF_DB_NODE_ID: 1
|
||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||
image: cerc/go-ethereum:local
|
||||
entrypoint: /bin/sh
|
||||
command: -c "/opt/run-geth.sh"
|
||||
volumes:
|
||||
- mainnet_eth_geth_1_data:/root/ethdata
|
||||
- mainnet_eth_config_data:/etc/mainnet-eth
|
||||
- ../config/mainnet-eth/scripts/run-geth.sh:/opt/run-geth.sh
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-v", "localhost", "8545"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 3s
|
||||
ports:
|
||||
- "8545"
|
||||
- "40000"
|
||||
- "6060"
|
||||
|
||||
mainnet-eth-lighthouse-1:
|
||||
restart: always
|
||||
hostname: mainnet-eth-lighthouse-1
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--tries=1", "--connect-timeout=1", "--quiet", "-O", "-", "http://localhost:8001/eth/v2/beacon/blocks/head"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 30s
|
||||
environment:
|
||||
EXECUTION_ENDPOINT: "http://mainnet-eth-geth-1:8551"
|
||||
image: cerc/lighthouse:local
|
||||
entrypoint: /bin/sh
|
||||
command: -c "/opt/run-lighthouse.sh"
|
||||
volumes:
|
||||
- mainnet_eth_lighthouse_1_data:/var/lighthouse-data-dir
|
||||
- mainnet_eth_config_data:/etc/mainnet-eth
|
||||
- ../config/mainnet-eth/scripts/run-lighthouse.sh:/opt/run-lighthouse.sh
|
||||
ports:
|
||||
- "8001"
|
||||
|
||||
volumes:
|
||||
mainnet_eth_config_data:
|
||||
mainnet_eth_geth_1_data:
|
||||
mainnet_eth_lighthouse_1_data:
|
||||
@@ -2,7 +2,7 @@ services:
|
||||
laconicd:
|
||||
restart: no
|
||||
image: cerc/laconicd:local
|
||||
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||
command: ["/bin/sh", "-c", "while :; do sleep 600; done"]
|
||||
volumes:
|
||||
# The cosmos-sdk node's database directory:
|
||||
- laconicd-data:/root/.laconicd/data
|
||||
|
||||
@@ -14,12 +14,14 @@ services:
|
||||
CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL}
|
||||
CERC_RELAY_NODES: ${CERC_RELAY_NODES}
|
||||
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
|
||||
CERC_BUILD_DIR: "@cerc-io/mobymask-ui/build"
|
||||
CERC_RELEASE: "v0.1.5"
|
||||
CERC_USE_NPM: true
|
||||
CERC_CONFIG_FILE: "src/config.json"
|
||||
working_dir: /scripts
|
||||
command: ["sh", "mobymask-app-start.sh"]
|
||||
volumes:
|
||||
- ../config/wait-for-it.sh:/scripts/wait-for-it.sh
|
||||
- ../config/watcher-mobymask-v2/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
|
||||
- ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json
|
||||
- peers_ids:/peers
|
||||
- mobymask_deployment:/server
|
||||
ports:
|
||||
@@ -46,12 +48,14 @@ services:
|
||||
CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL}
|
||||
CERC_RELAY_NODES: ${CERC_RELAY_NODES}
|
||||
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
|
||||
CERC_BUILD_DIR: "@cerc-io/mobymask-ui-lxdao/build"
|
||||
CERC_RELEASE: "v0.1.5-lxdao-0.1.1"
|
||||
CERC_USE_NPM: false
|
||||
CERC_CONFIG_FILE: "src/utils/config.json"
|
||||
working_dir: /scripts
|
||||
command: ["sh", "mobymask-app-start.sh"]
|
||||
volumes:
|
||||
- ../config/wait-for-it.sh:/scripts/wait-for-it.sh
|
||||
- ../config/watcher-mobymask-v2/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
|
||||
- ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json
|
||||
- peers_ids:/peers
|
||||
- mobymask_deployment:/server
|
||||
ports:
|
||||
|
||||
@@ -14,7 +14,7 @@ services:
|
||||
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
|
||||
command: ["sh", "test-app-start.sh"]
|
||||
volumes:
|
||||
- ../config/wait-for-it.sh:/scripts/wait-for-it.sh
|
||||
- ../config/network/wait-for-it.sh:/scripts/wait-for-it.sh
|
||||
- ../config/watcher-mobymask-v2/test-app-start.sh:/scripts/test-app-start.sh
|
||||
- peers_ids:/peers
|
||||
ports:
|
||||
|
||||
@@ -44,7 +44,7 @@ services:
|
||||
CERC_L2_NODE_PORT: ${CERC_L2_NODE_PORT}
|
||||
command: ["sh", "deploy-and-generate-invite.sh"]
|
||||
volumes:
|
||||
- ../config/wait-for-it.sh:/app/packages/server/wait-for-it.sh
|
||||
- ../config/network/wait-for-it.sh:/app/packages/server/wait-for-it.sh
|
||||
- ../config/watcher-mobymask-v2/secrets-template.json:/app/packages/server/secrets-template.json
|
||||
- ../config/watcher-mobymask-v2/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh
|
||||
- mobymask_deployment:/app/packages/server
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
See: https://docs.plugeth.org/
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
CERC_ETH_DATADIR=/root/ethdata
|
||||
|
||||
START_CMD="geth"
|
||||
if [ "true" == "$CERC_REMOTE_DEBUG" ] && [ -x "/usr/local/bin/dlv" ]; then
|
||||
START_CMD="/usr/local/bin/dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/geth --continue --"
|
||||
fi
|
||||
|
||||
# See https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script
|
||||
cleanup() {
|
||||
echo "Signal received, cleaning up..."
|
||||
|
||||
# Kill the child process first (CERC_REMOTE_DEBUG=true uses dlv which starts geth as a child process)
|
||||
pkill -P ${geth_pid}
|
||||
sleep 2
|
||||
kill $(jobs -p)
|
||||
|
||||
wait
|
||||
echo "Done"
|
||||
}
|
||||
|
||||
$START_CMD \
|
||||
--datadir="${CERC_ETH_DATADIR}" \
|
||||
--authrpc.addr="0.0.0.0" \
|
||||
--authrpc.port 8551 \
|
||||
--authrpc.vhosts="*" \
|
||||
--authrpc.jwtsecret="/etc/mainnet-eth/jwtsecret" \
|
||||
--ws \
|
||||
--ws.addr="0.0.0.0" \
|
||||
--ws.origins="*" \
|
||||
--ws.api="${CERC_GETH_WS_APIS:-eth,web3,net,admin,personal,debug,statediff}" \
|
||||
--http.corsdomain="*" \
|
||||
--gcmode full \
|
||||
--txlookuplimit=0 \
|
||||
--cache.preimages \
|
||||
--syncmode=snap \
|
||||
&
|
||||
|
||||
geth_pid=$!
|
||||
|
||||
|
||||
wait $geth_pid
|
||||
|
||||
if [ "true" == "$CERC_KEEP_RUNNING_AFTER_GETH_EXIT" ]; then
|
||||
while [ 1 -eq 1 ]; do
|
||||
sleep 60
|
||||
done
|
||||
fi
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
DEBUG_LEVEL=${CERC_LIGHTHOUSE_DEBUG_LEVEL:-info}
|
||||
|
||||
data_dir=/var/lighthouse-data-dir
|
||||
|
||||
network_port=9001
|
||||
http_port=8001
|
||||
authrpc_port=8551
|
||||
|
||||
exec lighthouse \
|
||||
bn \
|
||||
--debug-level $DEBUG_LEVEL \
|
||||
--datadir $data_dir \
|
||||
--network mainnet \
|
||||
--execution-endpoint $EXECUTION_ENDPOINT \
|
||||
--execution-jwt /etc/mainnet-eth/jwtsecret \
|
||||
--disable-deposit-contract-sync \
|
||||
--checkpoint-sync-url https://beaconstate.ethstaker.cc
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "MobyMask",
|
||||
"relayNodes": [],
|
||||
"peer": {
|
||||
"enableDebugInfo": true
|
||||
}
|
||||
}
|
||||
@@ -33,11 +33,23 @@ else
|
||||
echo "Taking deployed contract details from env"
|
||||
fi
|
||||
|
||||
# Use yq to create config.yml with environment variables
|
||||
yq -n ".address = env(CERC_DEPLOYED_CONTRACT)" > /config/config.yml
|
||||
yq ".watcherUrl = env(CERC_APP_WATCHER_URL)" -i /config/config.yml
|
||||
yq ".chainId = env(CERC_CHAIN_ID)" -i /config/config.yml
|
||||
yq ".relayNodes = strenv(CERC_RELAY_NODES)" -i /config/config.yml
|
||||
yq ".denyMultiaddrs = strenv(CERC_DENY_MULTIADDRS)" -i /config/config.yml
|
||||
cd /app
|
||||
git checkout $CERC_RELEASE
|
||||
|
||||
/scripts/start-serving-app.sh
|
||||
# Export config values in a json file
|
||||
jq --arg address "$CERC_DEPLOYED_CONTRACT" \
|
||||
--argjson chainId "$CERC_CHAIN_ID" \
|
||||
--argjson relayNodes "$CERC_RELAY_NODES" \
|
||||
--argjson denyMultiaddrs "$CERC_DENY_MULTIADDRS" \
|
||||
'.address = $address | .chainId = $chainId | .relayNodes = $relayNodes | .peer.denyMultiaddrs = $denyMultiaddrs' \
|
||||
/app/src/mobymask-app-config.json > /app/${CERC_CONFIG_FILE}
|
||||
|
||||
if [ "${CERC_USE_NPM}" = "true" ]; then
|
||||
npm install
|
||||
REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" npm run build
|
||||
else
|
||||
yarn install
|
||||
REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" yarn build
|
||||
fi
|
||||
|
||||
http-server -p 80 /app/build
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen
|
||||
|
||||
FROM golang:1.20-alpine as builder
|
||||
|
||||
RUN apk add --no-cache python3 py3-pip
|
||||
|
||||
COPY genesis /opt/genesis
|
||||
|
||||
# Install ethereum-genesis-generator tools
|
||||
COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/
|
||||
COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/
|
||||
COPY --from=ethgen /apps /apps
|
||||
RUN cd /apps/el-gen && pip3 install -r requirements.txt
|
||||
# web3==5.24.0 used by el-gen is broken on python 3.11
|
||||
RUN pip3 install --upgrade "web3==6.5.0"
|
||||
|
||||
# Build genesis config
|
||||
RUN apk add --no-cache make bash envsubst jq
|
||||
RUN cd /opt/genesis && make genesis-el
|
||||
|
||||
# Snag the genesis block info.
|
||||
RUN go install github.com/cerc-io/eth-dump-genblock@latest
|
||||
RUN eth-dump-genblock /opt/genesis/build/el/geth.json > /opt/genesis/build/el/genesis_block.json
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
COPY --from=builder /opt/genesis /opt/genesis
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/fixturenet-eth-genesis
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/fixturenet-eth-genesis:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR
|
||||
@@ -1,39 +1,21 @@
|
||||
FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen
|
||||
|
||||
# Using the same golang image as used to build geth: https://github.com/cerc-io/go-ethereum/blob/HEAD/Dockerfile
|
||||
FROM golang:1.18-alpine as delve
|
||||
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|
||||
|
||||
FROM cerc/fixturenet-eth-genesis:local as fnetgen
|
||||
FROM cerc/go-ethereum:local as geth
|
||||
|
||||
# Using the same golang image as used to build geth: https://github.com/cerc-io/go-ethereum/blob/HEAD/Dockerfile
|
||||
FROM golang:1.20-alpine as delve
|
||||
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|
||||
|
||||
FROM alpine:3.17
|
||||
RUN apk add --no-cache python3 python3-dev py3-pip curl wget jq build-base gettext libintl openssl bash bind-tools postgresql-client
|
||||
|
||||
COPY --from=delve /go/bin/dlv /usr/local/bin/
|
||||
COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/
|
||||
COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/
|
||||
COPY --from=ethgen /apps /apps
|
||||
RUN apk add --no-cache bash wget python3 bind-tools postgresql-client
|
||||
|
||||
RUN cd /apps/el-gen && pip3 install -r requirements.txt
|
||||
|
||||
COPY genesis /opt/testnet
|
||||
COPY run-el.sh /opt/testnet/run.sh
|
||||
|
||||
RUN cd /opt/testnet && make genesis-el
|
||||
COPY --from=delve /go/bin/dlv /usr/local/bin/
|
||||
COPY --from=geth /usr/local/bin/geth /usr/local/bin/
|
||||
COPY --from=fnetgen /opt/genesis /opt/testnet
|
||||
|
||||
COPY --from=geth /usr/local/bin/geth /usr/local/bin/
|
||||
|
||||
# Snag the genesis block info.
|
||||
# Initialize the geth db with our config
|
||||
RUN geth --datadir ~/ethdata init /opt/testnet/build/el/geth.json && rm -f ~/ethdata/geth/nodekey
|
||||
RUN cp -rp ~/ethdata ~/tmpeth && \
|
||||
geth --datadir ~/tmpeth init /opt/testnet/build/el/geth.json && \
|
||||
geth --datadir ~/tmpeth --http & \
|
||||
sleep 5 && \
|
||||
curl -q --location 'localhost:8545' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{ "jsonrpc": "2.0", "id": 14, "method": "eth_getBlockByNumber", "params": ["0x0", false] }' \
|
||||
-o /opt/testnet/build/el/genesis_block.json && \
|
||||
killall -9 geth && \
|
||||
rm -rf ~/tmpeth
|
||||
|
||||
ENTRYPOINT ["/opt/testnet/run.sh"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FROM cerc/lighthouse-cli:local AS lcli
|
||||
FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen
|
||||
FROM cerc/fixturenet-eth-geth:local AS fnetgeth
|
||||
FROM cerc/fixturenet-eth-genesis:local AS fnetgen
|
||||
|
||||
FROM cerc/lighthouse:local
|
||||
|
||||
@@ -19,8 +19,8 @@ COPY --from=lcli /usr/local/bin/lcli /usr/local/bin/lcli
|
||||
COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/eth2-testnet-genesis
|
||||
COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/eth2-val-tools
|
||||
COPY --from=ethgen /apps /apps
|
||||
COPY --from=fnetgeth /opt/testnet/el /opt/testnet/el
|
||||
COPY --from=fnetgeth /opt/testnet/build/el /opt/testnet/build/el
|
||||
COPY --from=fnetgen /opt/genesis/el /opt/testnet/el
|
||||
COPY --from=fnetgen /opt/genesis/build/el /opt/testnet/build/el
|
||||
|
||||
RUN cd /opt/testnet && make genesis-cl
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ EXECUTION_ENDPOINT=${EXECUTION_ENDPOINT:-http://localhost:8551}
|
||||
ETH1_GENESIS_JSON=${ETH1_GENESIS_JSON:-"../build/el/geth.json"}
|
||||
ETH1_GENESIS_BLOCK_JSON=${ETH1_GENESIS_BLOCK_JSON:-"../build/el/genesis_block.json"}
|
||||
ETH1_CONFIG_YAML=${ETH1_CONFIG_YAML:-"../el/el-config.yaml"}
|
||||
ETH1_BLOCK_HASH=${ETH1_BLOCK_HASH:-`cat $ETH1_GENESIS_BLOCK_JSON | jq -r '.result.hash' | cut -d'x' -f2`}
|
||||
ETH1_BLOCK_HASH=${ETH1_BLOCK_HASH:-`cat $ETH1_GENESIS_BLOCK_JSON | jq -r '.hash' | cut -d'x' -f2`}
|
||||
|
||||
ETH1_CHAIN_ID=${ETH1_CHAIN_ID:-`cat $ETH1_GENESIS_JSON | jq -r '.config.chainId'`}
|
||||
ETH1_TTD=${ETH1_TTD:-`cat $ETH1_GENESIS_JSON | jq -r '.config.terminalTotalDifficulty'`}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
FROM cerc/lighthouse-cli:local AS lcli
|
||||
FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen
|
||||
FROM cerc/fixturenet-plugeth-plugeth:local AS fnetgeth
|
||||
|
||||
FROM cerc/lighthouse:local
|
||||
|
||||
# cerc/lighthouse is based on Ubuntu
|
||||
RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends \
|
||||
libssl-dev ca-certificates \
|
||||
curl socat iproute2 telnet wget jq \
|
||||
build-essential python3 python3-dev python3-pip gettext-base \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY genesis /opt/testnet
|
||||
COPY run-cl.sh /opt/testnet/run.sh
|
||||
|
||||
COPY --from=lcli /usr/local/bin/lcli /usr/local/bin/lcli
|
||||
COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/eth2-testnet-genesis
|
||||
COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/eth2-val-tools
|
||||
COPY --from=ethgen /apps /apps
|
||||
COPY --from=fnetgeth /opt/testnet/el /opt/testnet/el
|
||||
COPY --from=fnetgeth /opt/testnet/build/el /opt/testnet/build/el
|
||||
|
||||
RUN cd /opt/testnet && make genesis-cl
|
||||
|
||||
# Work around some bugs in lcli where the default path is always used.
|
||||
RUN mkdir -p /root/.lighthouse && cd /root/.lighthouse && ln -s /opt/testnet/build/cl/testnet
|
||||
|
||||
RUN mkdir -p /scripts
|
||||
COPY scripts/status-internal.sh /scripts
|
||||
COPY scripts/status.sh /scripts
|
||||
|
||||
ENTRYPOINT ["/opt/testnet/run.sh"]
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/fixturenet-plugeth-lighthouse
|
||||
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
if [ ! -d "${SCRIPT_DIR}/genesis" ]; then
|
||||
cp -frp ${SCRIPT_DIR}/../cerc-fixturenet-eth-lighthouse/genesis ${SCRIPT_DIR}/genesis
|
||||
fi
|
||||
|
||||
if [ ! -e "${SCRIPT_DIR}/run-cl.sh" ]; then
|
||||
cp -fp ${SCRIPT_DIR}/../cerc-fixturenet-eth-lighthouse/run-cl.sh ${SCRIPT_DIR}/
|
||||
fi
|
||||
|
||||
if [ ! -d "${SCRIPT_DIR}/scripts" ]; then
|
||||
cp -frp ${SCRIPT_DIR}/../cerc-fixturenet-eth-lighthouse/scripts ${SCRIPT_DIR}/
|
||||
fi
|
||||
|
||||
docker build -t cerc/fixturenet-plugeth-lighthouse:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} $SCRIPT_DIR
|
||||
@@ -1,42 +1,25 @@
|
||||
FROM skylenet/ethereum-genesis-generator@sha256:210353ce7c898686bc5092f16c61220a76d357f51eff9c451e9ad1b9ad03d4d3 AS ethgen
|
||||
FROM cerc/fixturenet-eth-genesis:local as fnetgen
|
||||
|
||||
FROM golang:1.19-alpine as delve
|
||||
# Using the same golang image as used to build geth: https://github.com/cerc-io/go-ethereum/blob/HEAD/Dockerfile
|
||||
FROM golang:1.20-alpine as delve
|
||||
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|
||||
|
||||
FROM cerc/plugeth:local as geth
|
||||
FROM cerc/plugeth-statediff:local as statediff
|
||||
# FIXME: fork of plugeth, use stock after upstreaming patches
|
||||
FROM cerc/plugeth:local as geth
|
||||
|
||||
FROM alpine:3.17
|
||||
RUN apk add --no-cache python3 python3-dev py3-pip curl wget jq build-base gettext libintl openssl bash bind-tools postgresql-client
|
||||
|
||||
COPY --from=delve /go/bin/dlv /usr/local/bin/
|
||||
COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/
|
||||
COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/
|
||||
COPY --from=ethgen /apps /apps
|
||||
RUN apk add --no-cache bash wget python3 bind-tools postgresql-client
|
||||
|
||||
RUN cd /apps/el-gen && pip3 install -r requirements.txt
|
||||
|
||||
COPY genesis /opt/testnet
|
||||
COPY run-el.sh /opt/testnet/run.sh
|
||||
|
||||
RUN cd /opt/testnet && make genesis-el
|
||||
|
||||
COPY --from=geth /usr/local/bin/geth /usr/local/bin/
|
||||
|
||||
RUN mkdir -p /usr/local/lib/plugeth/
|
||||
COPY --from=delve /go/bin/dlv /usr/local/bin/
|
||||
COPY --from=geth /usr/local/bin/geth /usr/local/bin/
|
||||
COPY --from=fnetgen /opt/genesis /opt/testnet
|
||||
COPY --from=statediff /usr/local/lib/statediff.so /usr/local/lib/plugeth/
|
||||
|
||||
# Snag the genesis block info.
|
||||
# Initialize the geth db with our config
|
||||
RUN geth --datadir ~/ethdata init /opt/testnet/build/el/geth.json && rm -f ~/ethdata/geth/nodekey
|
||||
RUN cp -rp ~/ethdata ~/tmpeth && \
|
||||
geth --datadir ~/tmpeth init /opt/testnet/build/el/geth.json && \
|
||||
geth --datadir ~/tmpeth --http & \
|
||||
sleep 5 && \
|
||||
curl -q --location 'localhost:8545' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{ "jsonrpc": "2.0", "id": 14, "method": "eth_getBlockByNumber", "params": ["0x0", false] }' \
|
||||
-o /opt/testnet/build/el/genesis_block.json && \
|
||||
killall -9 geth && \
|
||||
rm -rf ~/tmpeth
|
||||
|
||||
ENTRYPOINT ["/opt/testnet/run.sh"]
|
||||
|
||||
@@ -6,10 +6,6 @@ source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
if [ ! -d "${SCRIPT_DIR}/genesis" ]; then
|
||||
cp -frp ${SCRIPT_DIR}/../cerc-fixturenet-eth-geth/genesis ${SCRIPT_DIR}/genesis
|
||||
fi
|
||||
|
||||
if [ ! -e "${SCRIPT_DIR}/run-el.sh" ]; then
|
||||
cp -fp ${SCRIPT_DIR}/../cerc-fixturenet-eth-geth/run-el.sh ${SCRIPT_DIR}/
|
||||
fi
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
ARG TAG_SUFFIX="-modern"
|
||||
FROM sigp/lighthouse:v4.1.0${TAG_SUFFIX}
|
||||
FROM sigp/lighthouse:v4.3.0${TAG_SUFFIX}
|
||||
|
||||
RUN apt-get update; apt-get install bash netcat curl less jq -y;
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@ FROM node:${VARIANT}
|
||||
ARG USERNAME=node
|
||||
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
||||
|
||||
# This container pulls npm package from a registry configured via env var
|
||||
ARG CERC_NPM_REGISTRY_URL
|
||||
|
||||
# Add NPM global to PATH.
|
||||
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
|
||||
# Prevents npm from printing version warnings
|
||||
@@ -33,28 +30,14 @@ RUN \
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get -y install --no-install-recommends jq bash netcat
|
||||
|
||||
# We do this to get a yq binary from the published container, for the correct architecture we're building here
|
||||
COPY --from=docker.io/mikefarah/yq:latest /usr/bin/yq /usr/local/bin/yq
|
||||
|
||||
RUN mkdir -p /scripts
|
||||
COPY ./apply-webapp-config.sh /scripts
|
||||
COPY ./start-serving-app.sh /scripts
|
||||
|
||||
# Configure the local npm registry
|
||||
RUN npm config set @cerc-io:registry ${CERC_NPM_REGISTRY_URL}
|
||||
|
||||
RUN mkdir -p /config
|
||||
|
||||
# Install simple web server for now (use nginx perhaps later)
|
||||
RUN yarn global add http-server
|
||||
|
||||
# Globally install both versions of the payload web app package
|
||||
# Install old version of MobyMask web app
|
||||
RUN yarn global add @cerc-io/mobymask-ui@0.1.4
|
||||
# Install the LXDAO version of MobyMask web app
|
||||
RUN yarn global add @cerc-io/mobymask-ui-lxdao@npm:@cerc-io/mobymask-ui@0.1.4-lxdao-0.1.1
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN npm install
|
||||
|
||||
# Expose port for http
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["/scripts/start-serving-app.sh"]
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
if [[ $# -ne 3 ]]; then
|
||||
echo "Illegal number of parameters" >&2
|
||||
exit 1
|
||||
fi
|
||||
config_file_name=$1
|
||||
webapp_files_dir=$2
|
||||
config_prefix=$3
|
||||
if ! [[ -f ${config_file_name} ]]; then
|
||||
echo "Config file ${config_file_name} does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! [[ -d ${webapp_files_dir} ]]; then
|
||||
echo "Webapp directory ${webapp_files_dir} does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
# First some magic using sed to translate our yaml config file into an array of key value pairs like:
|
||||
# ${config_prefix}<path-through-objects>=<value>
|
||||
# sed "s/'//g" is used to remove single quote for relayNodes value
|
||||
readarray -t config_kv_pair_array < <( sed -E 's/([^:]+):\s*(.*)/\1=\2/g' ${config_file_name} | sed "s/'//g" | sed "s/^/${config_prefix}_/" )
|
||||
declare -p config_kv_pair_array
|
||||
# Then iterate over that kv array making the template substitution in our web app files
|
||||
for kv_pair_string in "${config_kv_pair_array[@]}"
|
||||
do
|
||||
kv_pair=(${kv_pair_string//=/ })
|
||||
template_string_to_replace=${kv_pair[0]}
|
||||
template_value_to_substitute=${kv_pair[1]}
|
||||
# Run find and sed to do the substitution of one variable over all files
|
||||
# See: https://stackoverflow.com/a/21479607/1701505
|
||||
echo "Substituting: ${template_string_to_replace} = ${template_value_to_substitute}"
|
||||
|
||||
# TODO: Pass keys to be replaced without double quotes
|
||||
if [[ "$template_string_to_replace" =~ ^${config_prefix}_(relayNodes|chainId|denyMultiaddrs)$ ]]; then
|
||||
find ${webapp_files_dir} -type f -exec sed -i 's#"'"${template_string_to_replace}"'"#'"${template_value_to_substitute}"'#g' {} +
|
||||
else
|
||||
# Note: we do not escape our strings, on the expectation they do not container the '#' char.
|
||||
find ${webapp_files_dir} -type f -exec sed -i 's#'${template_string_to_replace}'#'${template_value_to_substitute}'#g' {} +
|
||||
fi
|
||||
done
|
||||
@@ -8,5 +8,4 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
CERC_NPM_REGISTRY_URL="https://git.vdb.to/api/packages/cerc-io/npm/"
|
||||
|
||||
docker build -t cerc/mobymask-ui:local ${build_command_args} -f ${SCRIPT_DIR}/Dockerfile \
|
||||
--build-arg CERC_NPM_REGISTRY_URL ${SCRIPT_DIR}
|
||||
docker build -t cerc/mobymask-ui:local ${build_command_args} -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/mobymask-ui
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# TODO: Don't hard wire this:
|
||||
webapp_files_dir="/usr/local/share/.config/yarn/global/node_modules/${CERC_BUILD_DIR}"
|
||||
/scripts/apply-webapp-config.sh /config/config.yml ${webapp_files_dir} MOBYMASK_HOSTED_CONFIG
|
||||
http-server -p 80 ${webapp_files_dir}
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/plugeth-statediff
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/plugeth-statediff:local ${build_command_args} ${CERC_REPO_BASE_DIR}/plugeth-statediff
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/plugeth
|
||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||
docker build -t cerc/plugeth:local ${build_command_args} ${CERC_REPO_BASE_DIR}/plugeth
|
||||
@@ -37,3 +37,5 @@ git.vdb.to/cerc-io/test-project
|
||||
github.com/Fantom-foundation/go-opera
|
||||
github.com/cerc-io/lasso
|
||||
github.com/paradigmxyz/reth
|
||||
git.vdb.to/cerc-io/plugeth
|
||||
git.vdb.to/cerc-io/plugeth-statediff
|
||||
|
||||
@@ -11,6 +11,7 @@ containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
- cerc/lighthouse-cli
|
||||
- cerc/fixturenet-eth-genesis
|
||||
- cerc/fixturenet-eth-geth
|
||||
- cerc/fixturenet-eth-lighthouse
|
||||
- cerc/ipld-eth-server
|
||||
|
||||
@@ -10,6 +10,7 @@ containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
- cerc/lighthouse-cli
|
||||
- cerc/fixturenet-eth-genesis
|
||||
- cerc/fixturenet-eth-geth
|
||||
- cerc/fixturenet-eth-lighthouse
|
||||
- cerc/tx-spammer
|
||||
|
||||
@@ -9,6 +9,7 @@ containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
- cerc/lighthouse-cli
|
||||
- cerc/fixturenet-eth-genesis
|
||||
- cerc/fixturenet-eth-geth
|
||||
- cerc/fixturenet-eth-lighthouse
|
||||
- cerc/foundry
|
||||
|
||||
@@ -11,6 +11,7 @@ containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
- cerc/lighthouse-cli
|
||||
- cerc/fixturenet-eth-genesis
|
||||
- cerc/fixturenet-eth-geth
|
||||
- cerc/fixturenet-eth-lighthouse
|
||||
- cerc/foundry
|
||||
|
||||
@@ -2,27 +2,28 @@ version: "1.2"
|
||||
name: fixturenet-plugeth-tx
|
||||
decription: "plugeth Ethereum Fixturenet w/ tx-spammer"
|
||||
repos:
|
||||
- github.com/cerc-io/tx-spammer
|
||||
- github.com/dboreham/foundry
|
||||
- git.vdb.to/cerc-io/plugeth@statediff-wip
|
||||
- git.vdb.to/cerc-io/plugeth-statediff
|
||||
- github.com/cerc-io/lighthouse
|
||||
- github.com/cerc-io/ipld-eth-db@v5
|
||||
- github.com/cerc-io/ipld-eth-server@v5
|
||||
- git.vdb.to/cerc-io/plugeth@statediff-wip
|
||||
- git.vdb.to/cerc-io/plugeth-statediff@dev-local-build
|
||||
- github.com/cerc-io/tx-spammer
|
||||
- github.com/dboreham/foundry
|
||||
containers:
|
||||
- cerc/lighthouse
|
||||
- cerc/lighthouse-cli
|
||||
- cerc/plugeth-statediff
|
||||
- cerc/plugeth
|
||||
- cerc/fixturenet-eth-genesis
|
||||
- cerc/fixturenet-plugeth-plugeth
|
||||
- cerc/fixturenet-plugeth-lighthouse
|
||||
- cerc/lighthouse
|
||||
- cerc/lighthouse-cli
|
||||
- cerc/fixturenet-eth-lighthouse
|
||||
- cerc/tx-spammer
|
||||
- cerc/foundry
|
||||
- cerc/ipld-eth-db
|
||||
- cerc/ipld-eth-server
|
||||
pods:
|
||||
- fixturenet-plugeth
|
||||
- ipld-eth-db
|
||||
- ipld-eth-server
|
||||
- fixturenet-plugeth
|
||||
- foundry
|
||||
- tx-spammer
|
||||
- foundry
|
||||
|
||||
@@ -10,6 +10,7 @@ containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
- cerc/lighthouse-cli
|
||||
- cerc/fixturenet-eth-genesis
|
||||
- cerc/fixturenet-eth-geth
|
||||
- cerc/fixturenet-eth-lighthouse
|
||||
- cerc/pocket
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
# mainnet-eth
|
||||
|
||||
Deploys a "head-tracking" mainnet Ethereum stack comprising a [go-ethereum](https://github.com/cerc-io/go-ethereum) execution layer node and a [lighthouse](https://github.com/sigp/lighthouse) consensus layer node.
|
||||
|
||||
## Clone required repositories
|
||||
|
||||
```
|
||||
$ laconic-so --stack mainnet-eth setup-repositories
|
||||
```
|
||||
|
||||
## Build containers
|
||||
|
||||
```
|
||||
$ laconic-so --stack mainnet-eth build-containers
|
||||
```
|
||||
|
||||
## Create a deployment
|
||||
|
||||
```
|
||||
$ laconic-so --stack mainnet-eth deploy init --output mainnet-eth-spec.yml
|
||||
$ laconic-so deploy create --spec-file mainnet-eth-spec.yml --deployment-dir mainnet-eth-deployment
|
||||
```
|
||||
## Start the stack
|
||||
```
|
||||
$ laconic-so deployment --dir mainnet-eth-deployment start
|
||||
```
|
||||
Display stack status:
|
||||
```
|
||||
$ laconic-so deployment --dir mainnet-eth-deployment ps
|
||||
Running containers:
|
||||
id: f39608eca04d72d6b0f1f3acefc5ebb52908da06e221d20c7138f7e3dff5e423, name: laconic-ef641b4d13eb61ed561b19be67063241-foundry-1, ports:
|
||||
id: 4052b1eddd886ae0d6b41f9ff22e68a70f267b2bfde10f4b7b79b5bd1eeddcac, name: laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-geth-1-1, ports: 30303/tcp, 30303/udp, 0.0.0.0:49184->40000/tcp, 0.0.0.0:49185->6060/tcp, 0.0.0.0:49186->8545/tcp, 8546/tcp
|
||||
id: ac331232e597944b621b3b8942ace5dafb14524302cab338ff946c7f6e5a1d52, name: laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1, ports: 0.0.0.0:49187->8001/tcp
|
||||
```
|
||||
See stack logs:
|
||||
```
|
||||
$ laconic-so deployment --dir mainnet-eth-deployment logs
|
||||
time="2023-07-25T09:46:29-06:00" level=warning msg="The \"CERC_SCRIPT_DEBUG\" variable is not set. Defaulting to a blank string."
|
||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.362 INFO Logging to file path: "/var/lighthouse-data-dir/beacon/logs/beacon.log"
|
||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.365 INFO Lighthouse started version: Lighthouse/v4.1.0-693886b
|
||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.365 INFO Configured for network name: mainnet
|
||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.366 INFO Data directory initialised datadir: /var/lighthouse-data-dir
|
||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.366 INFO Deposit contract address: 0x00000000219ab540356cbb839cbe05303d7705fa, deploy_block: 11184524
|
||||
laconic-ef641b4d13eb61ed561b19be67063241-mainnet-eth-lighthouse-1-1 | Jul 25 15:45:13.424 INFO Starting checkpoint sync remote_url: https://beaconstate.ethstaker.cc/, service: beacon
|
||||
```
|
||||
## Monitoring stack sync progress
|
||||
Both go-ethereum and lighthouse will engage in an initial chain sync phase that will last up to several hours depending on hardware performance and network capacity.
|
||||
Syncing can be monitored by looking for these log messages:
|
||||
```
|
||||
Jul 24 12:34:17.001 INFO Downloading historical blocks est_time: 5 days 11 hrs, speed: 14.67 slots/sec, distance: 6932481 slots (137 weeks 3 days), service: slot_notifier
|
||||
INFO [07-24|12:14:52.493] Syncing beacon headers downloaded=145,920 left=17,617,968 eta=1h23m32.815s
|
||||
INFO [07-24|12:33:15.238] Syncing: chain download in progress synced=1.86% chain=148.94MiB headers=368,640@95.03MiB bodies=330,081@40.56MiB receipts=330,081@13.35MiB eta=37m54.505s
|
||||
INFO [07-24|12:35:13.028] Syncing: state download in progress synced=1.32% state=4.64GiB accounts=2,850,314@677.57MiB slots=18,663,070@3.87GiB codes=26662@111.14MiB eta=3h18m0.699s
|
||||
```
|
||||
Once synced up these log messages will be observed:
|
||||
```
|
||||
INFO Synced slot: 6952515, block: 0x5bcb…f6d9, epoch: 217266, finalized_epoch: 217264, finalized_root: 0x6342…2c5c, exec_hash: 0x8d8c…2443 (verified), peers: 31, service: slot_notifier
|
||||
INFO [07-25|03:04:48.941] Imported new potential chain segment number=17,767,316 hash=84f6e7..bc2cb0 blocks=1 txs=137 mgas=16.123 elapsed=57.087ms mgasps=282.434 dirty=461.46MiB
|
||||
INFO [07-25|03:04:49.042] Chain head was updated number=17,767,316 hash=84f6e7..bc2cb0 root=ca58b2..8258c1 elapsed=2.480111ms
|
||||
```
|
||||
## Clean up
|
||||
|
||||
Stop the stack:
|
||||
```
|
||||
$ laconic-so deployment --dir mainnet-eth-deployment stop
|
||||
```
|
||||
This leaves data volumes in place, allowing the stack to be subsequently re-started.
|
||||
To permanently *delete* the stack's data volumes run:
|
||||
```
|
||||
$ laconic-so deployment --dir mainnet-eth-deployment stop --delete-data-volumes
|
||||
```
|
||||
After deleting the volumes, any subsequent re-start will begin chain sync from cold.
|
||||
## Data volumes
|
||||
Container data volumes are bind-mounted to specified paths in the host filesystem.
|
||||
The default setup (generated by `laconic-so deploy init`) places the volumes in the `./data` subdirectory of the deployment directory:
|
||||
```
|
||||
$ cat mainnet-eth-spec.yml
|
||||
stack: mainnet-eth
|
||||
volumes:
|
||||
mainnet_eth_config_data: ./data/mainnet_eth_config_data
|
||||
mainnet_eth_geth_1_data: ./data/mainnet_eth_geth_1_data
|
||||
mainnet_eth_lighthouse_1_data: ./data/mainnet_eth_lighthouse_1_data
|
||||
```
|
||||
A synced-up stack will consume around 900GB of data volume space:
|
||||
```
|
||||
$ sudo du -h mainnet-eth-deployment/data/
|
||||
150M mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data/beacon/freezer_db
|
||||
25G mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data/beacon/chain_db
|
||||
16K mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data/beacon/network
|
||||
368M mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data/beacon/logs
|
||||
26G mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data/beacon
|
||||
26G mainnet-eth-deployment/data/mainnet_eth_lighthouse_1_data
|
||||
8.0K mainnet-eth-deployment/data/mainnet_eth_config_data
|
||||
4.0K mainnet-eth-deployment/data/mainnet_eth_geth_1_data/keystore
|
||||
527G mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/chaindata/ancient/chain
|
||||
527G mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/chaindata/ancient
|
||||
859G mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/chaindata
|
||||
4.8M mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/nodes
|
||||
242M mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/ethash
|
||||
669M mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth/triecache
|
||||
860G mainnet-eth-deployment/data/mainnet_eth_geth_1_data/geth
|
||||
860G mainnet-eth-deployment/data/mainnet_eth_geth_1_data
|
||||
885G mainnet-eth-deployment/data/
|
||||
```
|
||||
@@ -0,0 +1,31 @@
|
||||
# Copyright © 2023 Cerc
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
from secrets import token_hex
|
||||
|
||||
def init(ctx):
|
||||
return None
|
||||
|
||||
|
||||
def setup(ctx):
|
||||
return None
|
||||
|
||||
|
||||
def create(ctx):
|
||||
# Generate the JWT secret and save to its config file
|
||||
secret = token_hex(32)
|
||||
jwt_file_path = ctx.deployment_dir.joinpath("data", "mainnet_eth_config_data", "jwtsecret")
|
||||
with open(jwt_file_path, 'w+') as jwt_file:
|
||||
jwt_file.write(secret)
|
||||
@@ -0,0 +1,15 @@
|
||||
version: "1.1"
|
||||
name: mainnet-eth
|
||||
decription: "Ethereum Mainnet"
|
||||
repos:
|
||||
- github.com/cerc-io/go-ethereum
|
||||
- github.com/cerc-io/lighthouse
|
||||
- github.com/dboreham/foundry
|
||||
containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
- cerc/lighthouse-cli
|
||||
- cerc/foundry
|
||||
pods:
|
||||
- mainnet-eth
|
||||
- foundry
|
||||
@@ -13,45 +13,39 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
import click
|
||||
import os
|
||||
from shutil import copyfile
|
||||
import sys
|
||||
from .util import get_stack_config_filename, get_parsed_deployment_spec
|
||||
from app.util import get_yaml
|
||||
from app.deploy_types import DeployCommandContext, DeploymentContext
|
||||
from app.stack_state import State
|
||||
from app.deploy_util import VolumeMapping, run_container_command
|
||||
|
||||
default_spec_file_content = """stack: mainnet-laconic
|
||||
data_dir: /my/path
|
||||
node_name: my-node-name
|
||||
default_spec_file_content = """config:
|
||||
node_moniker: my-node-name
|
||||
chain_id: my-chain-id
|
||||
"""
|
||||
|
||||
init_help_text = """Add helpful text here on setting config variables.
|
||||
"""
|
||||
|
||||
|
||||
def make_default_deployment_dir():
|
||||
return "deployment-001"
|
||||
|
||||
@click.command()
|
||||
@click.option("--output", required=True, help="Write yaml spec file here")
|
||||
@click.pass_context
|
||||
def init(ctx, output):
|
||||
with open(output, "w") as output_file:
|
||||
output_file.write(default_spec_file_content)
|
||||
def setup(command_context: DeployCommandContext):
|
||||
node_moniker = "dbdb-node"
|
||||
chain_id = "laconic_81337-1"
|
||||
mounts = [
|
||||
VolumeMapping("./path", "~/.laconicd")
|
||||
]
|
||||
output, status = run_container_command(command_context.cluster_context, "laconicd", f"laconicd init {node_moniker} --chain-id {chain_id}", mounts)
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--spec-file", required=True, help="Spec file to use to create this deployment")
|
||||
@click.option("--deployment-dir", help="Create deployment files in this directory")
|
||||
@click.pass_context
|
||||
def create(ctx, spec_file, deployment_dir):
|
||||
# This function fails with a useful error message if the file doens't exist
|
||||
parsed_spec = get_parsed_deployment_spec(spec_file)
|
||||
if ctx.debug:
|
||||
print(f"parsed spec: {parsed_spec}")
|
||||
if deployment_dir is None:
|
||||
deployment_dir = make_default_deployment_dir()
|
||||
if os.path.exists(deployment_dir):
|
||||
print(f"Error: {deployment_dir} already exists")
|
||||
sys.exit(1)
|
||||
os.mkdir(deployment_dir)
|
||||
# Copy spec file and the stack file into the deployment dir
|
||||
copyfile(spec_file, os.path.join(deployment_dir, os.path.basename(spec_file)))
|
||||
stack_file = get_stack_config_filename(parsed_spec.stack)
|
||||
copyfile(stack_file, os.path.join(deployment_dir, os.path.basename(stack_file)))
|
||||
def init(command_context: DeployCommandContext):
|
||||
print(init_help_text)
|
||||
yaml = get_yaml()
|
||||
return yaml.load(default_spec_file_content)
|
||||
|
||||
|
||||
def get_state(command_context: DeployCommandContext):
|
||||
print("Here we get state")
|
||||
return State.CONFIGURED
|
||||
|
||||
|
||||
def change_state(command_context: DeployCommandContext):
|
||||
pass
|
||||
|
||||
@@ -25,7 +25,4 @@ containers:
|
||||
pods:
|
||||
- mainnet-laconicd
|
||||
- fixturenet-laconic-console
|
||||
config:
|
||||
cli:
|
||||
key: laconicd.mykey
|
||||
address: laconicd.myaddress
|
||||
|
||||
|
||||
@@ -7,8 +7,9 @@ repos:
|
||||
- github.com/ethereum-optimism/optimism@v1.0.4
|
||||
- github.com/ethereum-optimism/op-geth@v1.101105.2
|
||||
- github.com/cerc-io/watcher-ts@v0.2.43
|
||||
- github.com/cerc-io/mobymask-v2-watcher-ts@v0.1.1
|
||||
- github.com/cerc-io/mobymask-v2-watcher-ts@v0.1.2
|
||||
- github.com/cerc-io/MobyMask@v0.1.2
|
||||
- github.com/cerc-io/mobymask-ui
|
||||
containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# Copyright © 2022, 2023 Cerc
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
from app.util import get_yaml
|
||||
from app.deploy_types import DeployCommandContext, DeploymentContext
|
||||
from app.stack_state import State
|
||||
from app.deploy_util import VolumeMapping, run_container_command
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
default_spec_file_content = """config:
|
||||
config_variable: test-value
|
||||
"""
|
||||
|
||||
init_help_text = """Add helpful text here on setting config variables.
|
||||
"""
|
||||
|
||||
# Output a known string to a know file in the bind mounted directory ./container-output-dir
|
||||
# for test purposes -- test checks that the file was written.
|
||||
def setup(command_context: DeployCommandContext, extra_args):
|
||||
host_directory = "./container-output-dir"
|
||||
host_directory_absolute = Path(extra_args[0]).absolute().joinpath(host_directory)
|
||||
host_directory_absolute.mkdir(parents=True, exist_ok=True)
|
||||
mounts = [
|
||||
VolumeMapping(host_directory_absolute, "/data")
|
||||
]
|
||||
output, status = run_container_command(command_context, "test", "echo output-data > /data/output-file && echo success", mounts)
|
||||
|
||||
|
||||
def init(command_context: DeployCommandContext):
|
||||
print(init_help_text)
|
||||
yaml = get_yaml()
|
||||
return yaml.load(default_spec_file_content)
|
||||
|
||||
|
||||
def create(command_context: DeployCommandContext):
|
||||
data = "create-command-output-data"
|
||||
output_file_path = command_context.deployment_dir.joinpath("create-file")
|
||||
with open(output_file_path, 'w+') as output_file:
|
||||
output_file.write(data)
|
||||
|
||||
|
||||
def get_state(command_context: DeployCommandContext):
|
||||
print("Here we get state")
|
||||
return State.CONFIGURED
|
||||
|
||||
|
||||
def change_state(command_context: DeployCommandContext):
|
||||
pass
|
||||
+20
-29
@@ -26,15 +26,11 @@ import subprocess
|
||||
from python_on_whales import DockerClient, DockerException
|
||||
import click
|
||||
from pathlib import Path
|
||||
from .util import include_exclude_check, get_parsed_stack_config, global_options2
|
||||
from .deployment_create import create as deployment_create
|
||||
from .deployment_create import init as deployment_init
|
||||
|
||||
|
||||
class DeployCommandContext(object):
|
||||
def __init__(self, cluster_context, docker):
|
||||
self.cluster_context = cluster_context
|
||||
self.docker = docker
|
||||
from app.util import include_exclude_check, get_parsed_stack_config, global_options2
|
||||
from app.deploy_types import ClusterContext, DeployCommandContext
|
||||
from app.deployment_create import create as deployment_create
|
||||
from app.deployment_create import init as deployment_init
|
||||
from app.deployment_create import setup as deployment_setup
|
||||
|
||||
|
||||
@click.group()
|
||||
@@ -57,10 +53,10 @@ def create_deploy_context(global_context, stack, include, exclude, cluster, env_
|
||||
# See: https://gabrieldemarmiesse.github.io/python-on-whales/sub-commands/compose/
|
||||
docker = DockerClient(compose_files=cluster_context.compose_files, compose_project_name=cluster_context.cluster,
|
||||
compose_env_file=cluster_context.env_file)
|
||||
return DeployCommandContext(cluster_context, docker)
|
||||
return DeployCommandContext(stack, cluster_context, docker)
|
||||
|
||||
|
||||
def up_operation(ctx, services_list):
|
||||
def up_operation(ctx, services_list, stay_attached=False):
|
||||
global_context = ctx.parent.parent.obj
|
||||
deploy_context = ctx.obj
|
||||
if not global_context.dry_run:
|
||||
@@ -72,7 +68,7 @@ def up_operation(ctx, services_list):
|
||||
print(f"Running compose up with container_exec_env: {container_exec_env}, extra_args: {services_list}")
|
||||
for pre_start_command in cluster_context.pre_start_commands:
|
||||
_run_command(global_context, cluster_context.cluster, pre_start_command)
|
||||
deploy_context.docker.compose.up(detach=True, services=services_list)
|
||||
deploy_context.docker.compose.up(detach=not stay_attached, services=services_list)
|
||||
for post_start_command in cluster_context.post_start_commands:
|
||||
_run_command(global_context, cluster_context.cluster, post_start_command)
|
||||
_orchestrate_cluster_config(global_context, cluster_context.config, deploy_context.docker, container_exec_env)
|
||||
@@ -148,14 +144,16 @@ def exec_operation(ctx, extra_args):
|
||||
print(f"container command returned error exit status")
|
||||
|
||||
|
||||
def logs_operation(ctx, extra_args):
|
||||
def logs_operation(ctx, tail: int, follow: bool, extra_args: str):
|
||||
global_context = ctx.parent.parent.obj
|
||||
extra_args_list = list(extra_args) or None
|
||||
if not global_context.dry_run:
|
||||
if global_context.verbose:
|
||||
print("Running compose logs")
|
||||
logs_output = ctx.obj.docker.compose.logs(services=extra_args_list if extra_args_list is not None else [])
|
||||
print(logs_output)
|
||||
services_list = extra_args_list if extra_args_list is not None else []
|
||||
logs_stream = ctx.obj.docker.compose.logs(services=services_list, tail=tail, follow=follow, stream=True)
|
||||
for stream_type, stream_content in logs_stream:
|
||||
print(stream_content.decode("utf-8"), end="")
|
||||
|
||||
|
||||
@command.command()
|
||||
@@ -196,10 +194,12 @@ def exec(ctx, extra_args):
|
||||
|
||||
|
||||
@command.command()
|
||||
@click.option("--tail", "-n", default=None, help="number of lines to display")
|
||||
@click.option("--follow", "-f", is_flag=True, default=False, help="follow log output")
|
||||
@click.argument('extra_args', nargs=-1) # help: command: logs <service1> <service2>
|
||||
@click.pass_context
|
||||
def logs(ctx, extra_args):
|
||||
logs_operation(ctx, extra_args)
|
||||
def logs(ctx, tail, follow, extra_args):
|
||||
logs_operation(ctx, tail, follow, extra_args)
|
||||
|
||||
|
||||
def get_stack_status(ctx, stack):
|
||||
@@ -263,7 +263,7 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
|
||||
print(f"Using cluster name: {cluster}")
|
||||
|
||||
# See: https://stackoverflow.com/a/20885799/1701505
|
||||
from . import data
|
||||
from app import data
|
||||
with resources.open_text(data, "pod-list.txt") as pod_list_file:
|
||||
all_pods = pod_list_file.read().splitlines()
|
||||
|
||||
@@ -312,17 +312,7 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
|
||||
if ctx.verbose:
|
||||
print(f"files: {compose_files}")
|
||||
|
||||
return cluster_context(cluster, compose_files, pre_start_commands, post_start_commands, cluster_config, env_file)
|
||||
|
||||
|
||||
class cluster_context:
|
||||
def __init__(self, cluster, compose_files, pre_start_commands, post_start_commands, config, env_file) -> None:
|
||||
self.cluster = cluster
|
||||
self.compose_files = compose_files
|
||||
self.pre_start_commands = pre_start_commands
|
||||
self.post_start_commands = post_start_commands
|
||||
self.config = config
|
||||
self.env_file = env_file
|
||||
return ClusterContext(cluster, compose_files, pre_start_commands, post_start_commands, cluster_config, env_file)
|
||||
|
||||
|
||||
def _convert_to_new_format(old_pod_array):
|
||||
@@ -420,3 +410,4 @@ def _orchestrate_cluster_config(ctx, cluster_config, docker, container_exec_env)
|
||||
|
||||
command.add_command(deployment_init)
|
||||
command.add_command(deployment_create)
|
||||
command.add_command(deployment_setup)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Copyright © 2023 Cerc
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
from typing import List
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from python_on_whales import DockerClient
|
||||
|
||||
@dataclass
|
||||
class ClusterContext:
|
||||
cluster: str
|
||||
compose_files: List[str]
|
||||
pre_start_commands: List[str]
|
||||
post_start_commands: List[str]
|
||||
config: str
|
||||
env_file: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class DeployCommandContext:
|
||||
stack: str
|
||||
cluster_context: ClusterContext
|
||||
docker: DockerClient
|
||||
|
||||
|
||||
@dataclass
|
||||
class DeploymentContext:
|
||||
deployment_dir: Path
|
||||
command_context: DeployCommandContext
|
||||
|
||||
|
||||
@dataclass
|
||||
class VolumeMapping:
|
||||
host_path: str
|
||||
container_path: str
|
||||
@@ -0,0 +1,56 @@
|
||||
# Copyright © 2022, 2023 Cerc
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
from dataclasses import dataclass
|
||||
from app.deploy_types import DeployCommandContext, VolumeMapping
|
||||
from app.util import get_parsed_stack_config, get_yaml, get_compose_file_dir
|
||||
|
||||
|
||||
def _container_image_from_service(stack:str, service: str):
|
||||
# Parse the compose files looking for the image name of the specified service
|
||||
image_name = None
|
||||
parsed_stack = get_parsed_stack_config(stack)
|
||||
pods = parsed_stack["pods"]
|
||||
yaml = get_yaml()
|
||||
for pod in pods:
|
||||
pod_file_path = os.path.join(get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
||||
parsed_pod_file = yaml.load(open(pod_file_path, "r"))
|
||||
if "services" in parsed_pod_file:
|
||||
services = parsed_pod_file["services"]
|
||||
if service in services:
|
||||
service_definition = services[service]
|
||||
if "image" in service_definition:
|
||||
image_name = service_definition["image"]
|
||||
return image_name
|
||||
|
||||
|
||||
def _volumes_to_docker(mounts: List[VolumeMapping]):
|
||||
# Example from doc: [("/", "/host"), ("/etc/hosts", "/etc/hosts", "rw")]
|
||||
result = []
|
||||
for mount in mounts:
|
||||
docker_volume = (mount.host_path, mount.container_path)
|
||||
result.append(docker_volume)
|
||||
return result
|
||||
|
||||
|
||||
def run_container_command(ctx: DeployCommandContext, service: str, command: str, mounts: List[VolumeMapping]):
|
||||
docker = ctx.docker
|
||||
container_image = _container_image_from_service(ctx.stack, service)
|
||||
docker_volumes = _volumes_to_docker(mounts)
|
||||
docker_output = docker.run(container_image, ["-c", command], entrypoint="bash", volumes=docker_volumes)
|
||||
# There doesn't seem to be a way to get an exit code from docker.run()
|
||||
return (docker_output, 0)
|
||||
+18
-24
@@ -17,8 +17,8 @@ import click
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from .deploy import up_operation, down_operation, ps_operation, port_operation, exec_operation, logs_operation, create_deploy_context
|
||||
from .util import global_options
|
||||
from app.deploy import up_operation, down_operation, ps_operation, port_operation, exec_operation, logs_operation, create_deploy_context
|
||||
from app.util import global_options
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -54,42 +54,46 @@ def make_deploy_context(ctx):
|
||||
|
||||
|
||||
@command.command()
|
||||
@click.option("--stay-attached/--detatch-terminal", default=False, help="detatch or not to see container stdout")
|
||||
@click.argument('extra_args', nargs=-1) # help: command: up <service1> <service2>
|
||||
@click.pass_context
|
||||
def up(ctx, extra_args):
|
||||
def up(ctx, stay_attached, extra_args):
|
||||
ctx.obj = make_deploy_context(ctx)
|
||||
services_list = list(extra_args) or None
|
||||
up_operation(ctx, services_list)
|
||||
up_operation(ctx, services_list, stay_attached)
|
||||
|
||||
|
||||
# start is the preferred alias for up
|
||||
@command.command()
|
||||
@click.option("--stay-attached/--detatch-terminal", default=False, help="detatch or not to see container stdout")
|
||||
@click.argument('extra_args', nargs=-1) # help: command: up <service1> <service2>
|
||||
@click.pass_context
|
||||
def start(ctx, extra_args):
|
||||
def start(ctx, stay_attached, extra_args):
|
||||
ctx.obj = make_deploy_context(ctx)
|
||||
services_list = list(extra_args) or None
|
||||
up_operation(ctx, services_list)
|
||||
up_operation(ctx, services_list, stay_attached)
|
||||
|
||||
|
||||
@command.command()
|
||||
@click.option("--delete-volumes/--preserve-volumes", default=False, help="delete data volumes")
|
||||
@click.argument('extra_args', nargs=-1) # help: command: down <service1> <service2>
|
||||
@click.pass_context
|
||||
def down(ctx, extra_args):
|
||||
def down(ctx, delete_volumes, extra_args):
|
||||
# Get the stack config file name
|
||||
# TODO: add cluster name and env file here
|
||||
ctx.obj = make_deploy_context(ctx)
|
||||
down_operation(ctx, extra_args, None)
|
||||
down_operation(ctx, delete_volumes, extra_args)
|
||||
|
||||
|
||||
# stop is the preferred alias for down
|
||||
@command.command()
|
||||
@click.option("--delete-volumes/--preserve-volumes", default=False, help="delete data volumes")
|
||||
@click.argument('extra_args', nargs=-1) # help: command: down <service1> <service2>
|
||||
@click.pass_context
|
||||
def stop(ctx, extra_args):
|
||||
def stop(ctx, delete_volumes, extra_args):
|
||||
# TODO: add cluster name and env file here
|
||||
ctx.obj = make_deploy_context(ctx)
|
||||
down_operation(ctx, extra_args, None)
|
||||
down_operation(ctx, delete_volumes, extra_args)
|
||||
|
||||
|
||||
@command.command()
|
||||
@@ -115,26 +119,16 @@ def exec(ctx, extra_args):
|
||||
|
||||
|
||||
@command.command()
|
||||
@click.option("--tail", "-n", default=None, help="number of lines to display")
|
||||
@click.option("--follow", "-f", is_flag=True, default=False, help="follow log output")
|
||||
@click.argument('extra_args', nargs=-1) # help: command: logs <service1> <service2>
|
||||
@click.pass_context
|
||||
def logs(ctx, extra_args):
|
||||
def logs(ctx, tail, follow, extra_args):
|
||||
ctx.obj = make_deploy_context(ctx)
|
||||
logs_operation(ctx, extra_args)
|
||||
logs_operation(ctx, tail, follow, extra_args)
|
||||
|
||||
|
||||
@command.command()
|
||||
@click.pass_context
|
||||
def status(ctx):
|
||||
print(f"Context: {ctx.parent.obj}")
|
||||
|
||||
|
||||
|
||||
#from importlib import resources, util
|
||||
# TODO: figure out how to do this dynamically
|
||||
#stack = "mainnet-laconic"
|
||||
#module_name = "commands"
|
||||
#spec = util.spec_from_file_location(module_name, "./app/data/stacks/" + stack + "/deploy/commands.py")
|
||||
#imported_stack = util.module_from_spec(spec)
|
||||
#spec.loader.exec_module(imported_stack)
|
||||
#command.add_command(imported_stack.init)
|
||||
#command.add_command(imported_stack.create)
|
||||
|
||||
+97
-27
@@ -14,42 +14,28 @@
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
import click
|
||||
from dataclasses import dataclass
|
||||
from importlib import util
|
||||
import os
|
||||
from pathlib import Path
|
||||
from shutil import copyfile, copytree
|
||||
import sys
|
||||
import ruamel.yaml
|
||||
from .util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options
|
||||
|
||||
|
||||
def _get_yaml():
|
||||
# See: https://stackoverflow.com/a/45701840/1701505
|
||||
yaml = ruamel.yaml.YAML()
|
||||
yaml.preserve_quotes = True
|
||||
yaml.indent(sequence=3, offset=1)
|
||||
return yaml
|
||||
from app.util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml, get_compose_file_dir
|
||||
from app.deploy_types import DeploymentContext, DeployCommandContext
|
||||
|
||||
|
||||
def _make_default_deployment_dir():
|
||||
return "deployment-001"
|
||||
|
||||
|
||||
def _get_compose_file_dir():
|
||||
# TODO: refactor to use common code with deploy command
|
||||
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
||||
data_dir = Path(__file__).absolute().parent.joinpath("data")
|
||||
source_compose_dir = data_dir.joinpath("compose")
|
||||
return source_compose_dir
|
||||
|
||||
|
||||
def _get_named_volumes(stack):
|
||||
# Parse the compose files looking for named volumes
|
||||
named_volumes = []
|
||||
parsed_stack = get_parsed_stack_config(stack)
|
||||
pods = parsed_stack["pods"]
|
||||
yaml = _get_yaml()
|
||||
yaml = get_yaml()
|
||||
for pod in pods:
|
||||
pod_file_path = os.path.join(_get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
||||
pod_file_path = os.path.join(get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
||||
parsed_pod_file = yaml.load(open(pod_file_path, "r"))
|
||||
if "volumes" in parsed_pod_file:
|
||||
volumes = parsed_pod_file["volumes"]
|
||||
@@ -96,21 +82,77 @@ def _fixup_pod_file(pod, spec, compose_dir):
|
||||
pod["volumes"][volume] = new_volume_spec
|
||||
|
||||
|
||||
def call_stack_deploy_init(deploy_command_context):
|
||||
# Link with the python file in the stack
|
||||
# Call a function in it
|
||||
# If no function found, return None
|
||||
python_file_path = get_stack_file_path(deploy_command_context.stack).parent.joinpath("deploy", "commands.py")
|
||||
spec = util.spec_from_file_location("commands", python_file_path)
|
||||
imported_stack = util.module_from_spec(spec)
|
||||
spec.loader.exec_module(imported_stack)
|
||||
return imported_stack.init(deploy_command_context)
|
||||
|
||||
|
||||
# TODO: fold this with function above
|
||||
def call_stack_deploy_setup(deploy_command_context, extra_args):
|
||||
# Link with the python file in the stack
|
||||
# Call a function in it
|
||||
# If no function found, return None
|
||||
python_file_path = get_stack_file_path(deploy_command_context.stack).parent.joinpath("deploy", "commands.py")
|
||||
spec = util.spec_from_file_location("commands", python_file_path)
|
||||
imported_stack = util.module_from_spec(spec)
|
||||
spec.loader.exec_module(imported_stack)
|
||||
return imported_stack.setup(deploy_command_context, extra_args)
|
||||
|
||||
|
||||
# TODO: fold this with function above
|
||||
def call_stack_deploy_create(deployment_context):
|
||||
# Link with the python file in the stack
|
||||
# Call a function in it
|
||||
# If no function found, return None
|
||||
python_file_path = get_stack_file_path(deployment_context.command_context.stack).parent.joinpath("deploy", "commands.py")
|
||||
spec = util.spec_from_file_location("commands", python_file_path)
|
||||
imported_stack = util.module_from_spec(spec)
|
||||
spec.loader.exec_module(imported_stack)
|
||||
return imported_stack.create(deployment_context)
|
||||
|
||||
|
||||
# Inspect the pod yaml to find config files referenced in subdirectories
|
||||
# other than the one associated with the pod
|
||||
def _find_extra_config_dirs(parsed_pod_file, pod):
|
||||
config_dirs = set()
|
||||
services = parsed_pod_file["services"]
|
||||
for service in services:
|
||||
service_info = services[service]
|
||||
if "volumes" in service_info:
|
||||
for volume in service_info["volumes"]:
|
||||
if ":" in volume:
|
||||
host_path = volume.split(":")[0]
|
||||
if host_path.startswith("../config"):
|
||||
config_dir = host_path.split("/")[2]
|
||||
if config_dir != pod:
|
||||
config_dirs.add(config_dir)
|
||||
return config_dirs
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--output", required=True, help="Write yaml spec file here")
|
||||
@click.pass_context
|
||||
def init(ctx, output):
|
||||
yaml = _get_yaml()
|
||||
yaml = get_yaml()
|
||||
stack = global_options(ctx).stack
|
||||
verbose = global_options(ctx).verbose
|
||||
default_spec_file_content = call_stack_deploy_init(ctx.obj)
|
||||
spec_file_content = {"stack": stack}
|
||||
if default_spec_file_content:
|
||||
spec_file_content.update(default_spec_file_content)
|
||||
if verbose:
|
||||
print(f"Creating spec file for stack: {stack}")
|
||||
named_volumes = _get_named_volumes(stack)
|
||||
if named_volumes:
|
||||
volume_descriptors = {}
|
||||
for named_volume in named_volumes:
|
||||
volume_descriptors[named_volume] = f"../data/{named_volume}"
|
||||
volume_descriptors[named_volume] = f"./data/{named_volume}"
|
||||
spec_file_content["volumes"] = volume_descriptors
|
||||
with open(output, "w") as output_file:
|
||||
yaml.dump(spec_file_content, output_file)
|
||||
@@ -142,14 +184,42 @@ def create(ctx, spec_file, deployment_dir):
|
||||
destination_compose_dir = os.path.join(deployment_dir, "compose")
|
||||
os.mkdir(destination_compose_dir)
|
||||
data_dir = Path(__file__).absolute().parent.joinpath("data")
|
||||
yaml = _get_yaml()
|
||||
yaml = get_yaml()
|
||||
for pod in pods:
|
||||
pod_file_path = os.path.join(_get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
||||
pod_file_path = os.path.join(get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
||||
parsed_pod_file = yaml.load(open(pod_file_path, "r"))
|
||||
extra_config_dirs = _find_extra_config_dirs(parsed_pod_file, pod)
|
||||
if global_options(ctx).debug:
|
||||
print(f"extra config dirs: {extra_config_dirs}")
|
||||
_fixup_pod_file(parsed_pod_file, parsed_spec, destination_compose_dir)
|
||||
with open(os.path.join(destination_compose_dir, os.path.basename(pod_file_path)), "w") as output_file:
|
||||
yaml.dump(parsed_pod_file, output_file)
|
||||
# Copy the config files for the pod, if any
|
||||
source_config_dir = data_dir.joinpath("config", pod)
|
||||
if os.path.exists(source_config_dir):
|
||||
copytree(source_config_dir, os.path.join(deployment_dir, "config", pod))
|
||||
config_dirs = {pod}
|
||||
config_dirs = config_dirs.union(extra_config_dirs)
|
||||
for config_dir in config_dirs:
|
||||
source_config_dir = data_dir.joinpath("config", config_dir)
|
||||
if os.path.exists(source_config_dir):
|
||||
destination_config_dir = os.path.join(deployment_dir, "config", config_dir)
|
||||
# If the same config dir appears in multiple pods, it may already have been copied
|
||||
if not os.path.exists(destination_config_dir):
|
||||
copytree(source_config_dir, destination_config_dir)
|
||||
# Delegate to the stack's Python code
|
||||
# The deploy create command doesn't require a --stack argument so we need to insert the
|
||||
# stack member here.
|
||||
deployment_command_context = ctx.obj
|
||||
deployment_command_context.stack = stack_name
|
||||
deployment_context = DeploymentContext(Path(deployment_dir), deployment_command_context)
|
||||
call_stack_deploy_create(deployment_context)
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--node-moniker", help="Help goes here")
|
||||
@click.option("--key-name", help="Help goes here")
|
||||
@click.option("--initialize-network", is_flag=True, default=False, help="Help goes here")
|
||||
@click.option("--join-network", is_flag=True, default=False, help="Help goes here")
|
||||
@click.option("--create-network", is_flag=True, default=False, help="Help goes here")
|
||||
@click.argument('extra_args', nargs=-1)
|
||||
@click.pass_context
|
||||
def setup(ctx, node_moniker, key_name, initialize_network, join_network, create_network, extra_args):
|
||||
call_stack_deploy_setup(ctx.obj, extra_args)
|
||||
|
||||
@@ -25,7 +25,7 @@ import click
|
||||
import importlib.resources
|
||||
from pathlib import Path
|
||||
import yaml
|
||||
from .util import include_exclude_check
|
||||
from app.util import include_exclude_check
|
||||
|
||||
|
||||
class GitProgress(git.RemoteProgress):
|
||||
@@ -227,7 +227,7 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches, branches
|
||||
os.makedirs(dev_root_path)
|
||||
|
||||
# See: https://stackoverflow.com/a/20885799/1701505
|
||||
from . import data
|
||||
from app import data
|
||||
with importlib.resources.open_text(data, "repository-list.txt") as repository_list_file:
|
||||
all_repos = repository_list_file.read().splitlines()
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Copyright © 2023 Cerc
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
from enum import Enum
|
||||
|
||||
class State(Enum):
|
||||
CREATED = 1
|
||||
CONFIGURED = 2
|
||||
STARTED = 3
|
||||
STOPPED = 4
|
||||
+19
-3
@@ -15,7 +15,7 @@
|
||||
|
||||
import os.path
|
||||
import sys
|
||||
import yaml
|
||||
import ruamel.yaml
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ def get_parsed_stack_config(stack):
|
||||
stack_file_path = stack if isinstance(stack, os.PathLike) else get_stack_file_path(stack)
|
||||
try:
|
||||
with stack_file_path:
|
||||
stack_config = yaml.safe_load(open(stack_file_path, "r"))
|
||||
stack_config = get_yaml().load(open(stack_file_path, "r"))
|
||||
return stack_config
|
||||
except FileNotFoundError as error:
|
||||
# We try here to generate a useful diagnostic error
|
||||
@@ -56,11 +56,19 @@ def get_parsed_stack_config(stack):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def get_compose_file_dir():
|
||||
# TODO: refactor to use common code with deploy command
|
||||
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
||||
data_dir = Path(__file__).absolute().parent.joinpath("data")
|
||||
source_compose_dir = data_dir.joinpath("compose")
|
||||
return source_compose_dir
|
||||
|
||||
|
||||
def get_parsed_deployment_spec(spec_file):
|
||||
spec_file_path = Path(spec_file)
|
||||
try:
|
||||
with spec_file_path:
|
||||
deploy_spec = yaml.safe_load(open(spec_file_path, "r"))
|
||||
deploy_spec = get_yaml().load(open(spec_file_path, "r"))
|
||||
return deploy_spec
|
||||
except FileNotFoundError as error:
|
||||
# We try here to generate a useful diagnostic error
|
||||
@@ -69,6 +77,14 @@ def get_parsed_deployment_spec(spec_file):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def get_yaml():
|
||||
# See: https://stackoverflow.com/a/45701840/1701505
|
||||
yaml = ruamel.yaml.YAML()
|
||||
yaml.preserve_quotes = True
|
||||
yaml.indent(sequence=3, offset=1)
|
||||
return yaml
|
||||
|
||||
|
||||
# TODO: this is fragile wrt to the subcommand depth
|
||||
# See also: https://github.com/pallets/click/issues/108
|
||||
def global_options(ctx):
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ def command(ctx):
|
||||
'''print tool version'''
|
||||
|
||||
# See: https://stackoverflow.com/a/20885799/1701505
|
||||
from . import data
|
||||
from app import data
|
||||
with importlib.resources.open_text(data, "build_tag.txt") as version_file:
|
||||
# TODO: code better version that skips comment lines
|
||||
version_string = version_file.read().splitlines()[1]
|
||||
|
||||
+7
-6
@@ -1,7 +1,8 @@
|
||||
python-decouple>=3.6
|
||||
GitPython>=3.1.27
|
||||
tqdm>=4.64.0
|
||||
python-on-whales>=0.58.0
|
||||
click>=8.1.3
|
||||
pyyaml>=6.0
|
||||
python-decouple>=3.8
|
||||
GitPython>=3.1.32
|
||||
tqdm>=4.65.0
|
||||
python-on-whales>=0.64.0
|
||||
click>=8.1.6
|
||||
PyYAML>=6.0.1
|
||||
ruamel.yaml>=0.17.32
|
||||
pydantic==1.10.9
|
||||
|
||||
@@ -23,6 +23,27 @@ mkdir -p $CERC_REPO_BASE_DIR
|
||||
# with and without volume removal
|
||||
$TEST_TARGET_SO --stack test setup-repositories
|
||||
$TEST_TARGET_SO --stack test build-containers
|
||||
# Test deploy command execution
|
||||
$TEST_TARGET_SO --stack test deploy setup $CERC_REPO_BASE_DIR
|
||||
# Check that we now have the expected output directory
|
||||
container_output_dir=$CERC_REPO_BASE_DIR/container-output-dir
|
||||
if [ ! -d "$container_output_dir" ]; then
|
||||
echo "deploy setup test: output directory not present"
|
||||
echo "deploy setup test: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$container_output_dir/output-file" ]; then
|
||||
echo "deploy setup test: output file not present"
|
||||
echo "deploy setup test: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
output_file_content=$(<$container_output_dir/output-file)
|
||||
if [ ! "$output_file_content" == "output-data" ]; then
|
||||
echo "deploy setup test: output file contents not correct"
|
||||
echo "deploy setup test: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
# Check that we now have the expected output file
|
||||
$TEST_TARGET_SO --stack test deploy up
|
||||
# Test deploy port command
|
||||
deploy_port_output=$( $TEST_TARGET_SO --stack test deploy port test 80 )
|
||||
@@ -53,4 +74,49 @@ else
|
||||
exit 1
|
||||
fi
|
||||
$TEST_TARGET_SO --stack test deploy down --delete-volumes
|
||||
# Basic test of creating a deployment
|
||||
test_deployment_dir=$CERC_REPO_BASE_DIR/test-deployment-dir
|
||||
test_deployment_spec=$CERC_REPO_BASE_DIR/test-deployment-spec.yml
|
||||
$TEST_TARGET_SO --stack test deploy init --output $test_deployment_spec
|
||||
# Check the file now exists
|
||||
if [ ! -f "$test_deployment_spec" ]; then
|
||||
echo "deploy init test: spec file not present"
|
||||
echo "deploy init test: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "deploy init test: passed"
|
||||
$TEST_TARGET_SO deploy create --spec-file $test_deployment_spec --deployment-dir $test_deployment_dir
|
||||
# Check the deployment dir exists
|
||||
if [ ! -d "$test_deployment_dir" ]; then
|
||||
echo "deploy create test: deployment directory not present"
|
||||
echo "deploy create test: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "deploy create test: passed"
|
||||
# Check the file writted by the create command in the stack now exists
|
||||
if [ ! -f "$test_deployment_dir/create-file" ]; then
|
||||
echo "deploy create test: create output file not present"
|
||||
echo "deploy create test: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
# And has the right content
|
||||
create_file_content=$(<$test_deployment_dir/create-file)
|
||||
if [ ! "$create_file_content" == "create-command-output-data" ]; then
|
||||
echo "deploy create test: create output file contents not correct"
|
||||
echo "deploy create test: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "deploy create output file test: passed"
|
||||
# Try to start the deployment
|
||||
$TEST_TARGET_SO deployment --dir $test_deployment_dir start
|
||||
# Check logs command works
|
||||
log_output_2=$( $TEST_TARGET_SO deployment --dir $test_deployment_dir logs )
|
||||
if [[ "$log_output_2" == *"Filesystem is fresh"* ]]; then
|
||||
echo "deployment logs test: passed"
|
||||
else
|
||||
echo "deployment logs test: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
# Stop and clean up
|
||||
$TEST_TARGET_SO deployment --dir $test_deployment_dir stop --delete-volumes
|
||||
echo "Test passed"
|
||||
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
echo "Running stack-orchestrator Ethereum mainnet test"
|
||||
# Bit of a hack, test the most recent package
|
||||
TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 )
|
||||
# Set a new unique repo dir
|
||||
export CERC_REPO_BASE_DIR=$(mktemp -d stack-orchestrator-mainnet-eth-test.XXXXXXXXXX)
|
||||
DEPLOYMENT_DIR=mainnet-eth-deployment-test
|
||||
echo "Testing this package: $TEST_TARGET_SO"
|
||||
echo "Test version command"
|
||||
reported_version_string=$( $TEST_TARGET_SO version )
|
||||
echo "Version reported is: ${reported_version_string}"
|
||||
echo "Cloning repositories into: $CERC_REPO_BASE_DIR"
|
||||
$TEST_TARGET_SO --stack mainnet-eth setup-repositories
|
||||
$TEST_TARGET_SO --stack mainnet-eth build-containers
|
||||
$TEST_TARGET_SO --stack mainnet-eth deploy init --output mainnet-eth-spec.yml
|
||||
$TEST_TARGET_SO deploy create --spec-file mainnet-eth-spec.yml --deployment-dir $DEPLOYMENT_DIR
|
||||
# Start the stack
|
||||
$TEST_TARGET_SO deployment --dir $DEPLOYMENT_DIR start
|
||||
# Verify that the stack is up and running
|
||||
$TEST_TARGET_SO deployment --dir $DEPLOYMENT_DIR ps
|
||||
#TODO: add a check that the container logs show good startup
|
||||
$TEST_TARGET_SO deployment --dir $DEPLOYMENT_DIR stop --delete-volumes
|
||||
echo "Removing deployment directory"
|
||||
rm -rf $DEPLOYMENT_DIR
|
||||
echo "Removing cloned repositories"
|
||||
rm -rf $CERC_REPO_BASE_DIR
|
||||
exit $test_result
|
||||
Reference in New Issue
Block a user