Archived
Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fce823123 | ||
|
|
dfedd9e9ff | ||
|
|
f64683f03b | ||
|
|
913c3a8557 | ||
|
|
2f5b0cdd13 | ||
|
|
432bd4113d | ||
|
|
b26698b756 | ||
|
|
01deac78c4 | ||
|
|
40ccd47857 | ||
|
|
80cff73344 | ||
|
|
21b1270d27 | ||
|
|
008389dcd8 | ||
|
|
c81fb9581a | ||
|
|
83397bbae4 | ||
|
|
17c21464ab | ||
|
|
7fb9ccdfd8 | ||
|
|
2bad59dfcd | ||
|
|
13d04e9256 | ||
|
|
1f017c9066 | ||
|
|
3b9422095c | ||
|
|
36d4969b2d | ||
|
|
a2d6201be9 | ||
|
|
62f7825ec2 | ||
|
|
6d24d4a7e6 | ||
|
|
f06e5f9a2a | ||
|
|
c3a1402042 |
@@ -5,3 +5,5 @@ Trigger
|
|||||||
Trigger
|
Trigger
|
||||||
Trigger
|
Trigger
|
||||||
Trigger
|
Trigger
|
||||||
|
Trigger
|
||||||
|
Trigger
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ $ laconic-so build-npms --include <package-name>
|
|||||||
```
|
```
|
||||||
e.g.
|
e.g.
|
||||||
```
|
```
|
||||||
$ laconic-so build-npms --include laconic-sdk
|
$ laconic-so build-npms --include registry-sdk
|
||||||
```
|
```
|
||||||
Build the packages for a stack:
|
Build the packages for a stack:
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ laconic-so --stack fixturenet-laconicd build-npms
|
|||||||
Navigate to the Gitea console and switch to the `cerc-io` user then find the `Packages` tab to confirm that these two npm packages have been published:
|
Navigate to the Gitea console and switch to the `cerc-io` user then find the `Packages` tab to confirm that these two npm packages have been published:
|
||||||
|
|
||||||
- `@cerc-io/laconic-registry-cli`
|
- `@cerc-io/laconic-registry-cli`
|
||||||
- `@cerc-io/laconic-sdk`
|
- `@cerc-io/registry-sdk`
|
||||||
|
|
||||||
### Build and deploy fixturenet containers
|
### Build and deploy fixturenet containers
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ laconic-so --stack fixturenet-laconicd deploy logs
|
|||||||
### Test with the registry CLI
|
### Test with the registry CLI
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
laconic-so --stack fixturenet-laconicd deploy exec cli "laconic cns status"
|
laconic-so --stack fixturenet-laconicd deploy exec cli "laconic registry status"
|
||||||
```
|
```
|
||||||
|
|
||||||
Try additional CLI commands, documented [here](https://github.com/cerc-io/laconic-registry-cli#operations).
|
Try additional CLI commands, documented [here](https://github.com/cerc-io/laconic-registry-cli#operations).
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
# Running a laconicd fixturenet with console
|
# Running a laconicd fixturenet with console
|
||||||
|
|
||||||
The following tutorial explains the steps to run a laconicd fixturenet with CLI and web console that displays records in the registry. It is designed as an introduction to Stack Orchestrator and to showcase one component of the Laconic Stack. Prior to Stack Orchestrator, the following 4 repositories had to be cloned and setup manually:
|
The following tutorial explains the steps to run a laconicd fixturenet with CLI and web console that displays records in the registry. It is designed as an introduction to Stack Orchestrator and to showcase one component of the Laconic Stack. Prior to Stack Orchestrator, the following repositories had to be cloned and setup manually:
|
||||||
|
|
||||||
- https://git.vdb.to/cerc-io/laconicd
|
- https://git.vdb.to/cerc-io/laconicd
|
||||||
- https://git.vdb.to/cerc-io/laconic-sdk
|
|
||||||
- https://git.vdb.to/cerc-io/laconic-registry-cli
|
- https://git.vdb.to/cerc-io/laconic-registry-cli
|
||||||
- https://git.vdb.to/cerc-io/laconic-console
|
- https://git.vdb.to/cerc-io/laconic-console
|
||||||
|
|
||||||
@@ -51,7 +50,7 @@ To avoid hiccups on Mac M1/M2 and any local machine nuances that may affect the
|
|||||||
1. Get the repositories
|
1. Get the repositories
|
||||||
|
|
||||||
```
|
```
|
||||||
laconic-so --stack fixturenet-laconic-loaded setup-repositories --include git.vdb.to/cerc-io/laconicd,git.vdb.to/cerc-io/laconic-sdk,git.vdb.to/cerc-io/laconic-registry-cli,git.vdb.to/cerc-io/laconic-console
|
laconic-so --stack fixturenet-laconic-loaded setup-repositories --include git.vdb.to/cerc-io/laconicd
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Build the containers:
|
1. Build the containers:
|
||||||
@@ -76,6 +75,8 @@ To avoid hiccups on Mac M1/M2 and any local machine nuances that may affect the
|
|||||||
1. Create a deployment directory for the stack:
|
1. Create a deployment directory for the stack:
|
||||||
```
|
```
|
||||||
laconic-so --stack fixturenet-laconic-loaded deploy init --output laconic-loaded.spec --map-ports-to-host any-same --config LACONIC_HOSTED_ENDPOINT=$BACKEND_ENDPOINT
|
laconic-so --stack fixturenet-laconic-loaded deploy init --output laconic-loaded.spec --map-ports-to-host any-same --config LACONIC_HOSTED_ENDPOINT=$BACKEND_ENDPOINT
|
||||||
|
|
||||||
|
# Update port mapping in the laconic-loaded.spec file to resolve port conflicts on host if any
|
||||||
```
|
```
|
||||||
```
|
```
|
||||||
laconic-so --stack fixturenet-laconic-loaded deploy create --deployment-dir laconic-loaded-deployment --spec-file laconic-loaded.spec
|
laconic-so --stack fixturenet-laconic-loaded deploy create --deployment-dir laconic-loaded-deployment --spec-file laconic-loaded.spec
|
||||||
@@ -95,52 +96,51 @@ To avoid hiccups on Mac M1/M2 and any local machine nuances that may affect the
|
|||||||
You'll see output from `laconicd` and the block height should be >1 to confirm it is running:
|
You'll see output from `laconicd` and the block height should be >1 to confirm it is running:
|
||||||
|
|
||||||
```
|
```
|
||||||
laconic-5cd0a80c1442c3044c8b295d26426bae-laconicd-1 | 9:29PM INF indexed block exents height=12 module=txindex server=node
|
laconicd-1 | 6:12AM INF indexed block events height=16 module=txindex
|
||||||
laconic-5cd0a80c1442c3044c8b295d26426bae-laconicd-1 | 9:30PM INF Timed out dur=4976.960115 height=13 module=consensus round=0 server=node step=1
|
laconicd-1 | 6:12AM INF Timed out dur=2993.893332 height=17 module=consensus round=0 step=RoundStepNewHeight
|
||||||
laconic-5cd0a80c1442c3044c8b295d26426bae-laconicd-1 | 9:30PM INF received proposal module=consensus proposal={"Type":32,"block_id":{"hash":"D26C088A711F912ADB97888C269F628DA33153795621967BE44DCB43C3D03CA4","parts":{"hash":"22411A20B7F14CDA33244420FBDDAF24450C0628C7A06034FF22DAC3699DDCC8","total":1}},"height":13,"pol_round":-1,"round":0,"signature":"DEuqnaQmvyYbUwckttJmgKdpRu6eVm9i+9rQ1pIrV2PidkMNdWRZBLdmNghkIrUzGbW8Xd7UVJxtLRmwRASgBg==","timestamp":"2023-04-18T21:30:01.49450663Z"} server=node
|
laconicd-1 | 6:12AM INF received proposal module=consensus proposal="Proposal{17/0 (E15D03C180CE607AE8340A1325A0C134DFB4E1ADD992E173C701EBD362523267:1:DF138772FEF0, -1) 6A6F3B0A42B3 @ 2024-07-25T06:12:31.952967053Z}" proposer=86970D950BC9C16F3991A52D9C6DC55BA478A7C6
|
||||||
laconic-5cd0a80c1442c3044c8b295d26426bae-laconicd-1 | 9:30PM INF received complete proposal block hash=D26C088A711F912ADB97888C269F628DA33153795621967BE44DCB43C3D03CA4 height=13 module=consensus server=node
|
laconicd-1 | 6:12AM INF received complete proposal block hash=E15D03C180CE607AE8340A1325A0C134DFB4E1ADD992E173C701EBD362523267 height=17 module=consensus
|
||||||
laconic-5cd0a80c1442c3044c8b295d26426bae-laconicd-1 | 9:30PM INF finalizing commit of block hash={} height=13 module=consensus num_txs=0 root=1A8CA1AF139CCC80EC007C6321D8A63A46A793386EE2EDF9A5CA0AB2C90728B7 server=node
|
laconicd-1 | 6:12AM INF finalizing commit of block hash=E15D03C180CE607AE8340A1325A0C134DFB4E1ADD992E173C701EBD362523267 height=17 module=consensus num_txs=0 root=AF4941107DC718ED1425E77A3DC7F1154FB780B7A7DE20288DC43442203527E3
|
||||||
laconic-5cd0a80c1442c3044c8b295d26426bae-laconicd-1 | 9:30PM INF minted coins from module account amount=2059730459416582643aphoton from=mint module=x/bank
|
laconicd-1 | 6:12AM INF finalized block block_app_hash=26A665360BB1EE64E54F97F2A5AB7F621B33A86D9896574000C05DE63F43F788 height=17 module=state num_txs_res=0 num_val_updates=0
|
||||||
laconic-5cd0a80c1442c3044c8b295d26426bae-laconicd-1 | 9:30PM INF executed block height=13 module=state num_invalid_txs=0 num_valid_txs=0 server=node
|
laconicd-1 | 6:12AM INF executed block app_hash=26A665360BB1EE64E54F97F2A5AB7F621B33A86D9896574000C05DE63F43F788 height=17 module=state
|
||||||
laconic-5cd0a80c1442c3044c8b295d26426bae-laconicd-1 | 9:30PM INF commit synced commit=436F6D6D697449447B5B363520313037203630203232372039352038352032303820313334203231392032303520313433203130372031343920313431203139203139322038362031323720362031383520323533203137362031333820313735203135392031383620323334203135382031323120313431203230342037335D3A447D
|
laconicd-1 | 6:12AM INF committed state block_app_hash=AF4941107DC718ED1425E77A3DC7F1154FB780B7A7DE20288DC43442203527E3 height=17 module=state
|
||||||
laconic-5cd0a80c1442c3044c8b295d26426bae-laconicd-1 | 9:30PM INF committed state app_hash=416B3CE35F55D086DBCD8F6B958D13C0567F06B9FDB08AAF9FBAEA9E798DCC49 height=13 module=state num_txs=0 server=node
|
laconicd-1 | 6:12AM INF indexed block events height=17 module=txindex
|
||||||
laconic-5cd0a80c1442c3044c8b295d26426bae-laconicd-1 | 9:30PM INF indexed block exents height=13 module=txindex server=node
|
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Confirm operation of the registry CLI:
|
4. Confirm operation of the registry CLI:
|
||||||
|
|
||||||
```
|
```
|
||||||
laconic-so deployment --dir laconic-loaded-deployment exec cli "laconic cns status"
|
laconic-so deployment --dir laconic-loaded-deployment exec cli "laconic registry status"
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
"node": {
|
"node": {
|
||||||
"id": "4216af2ac9f68bda33a38803fc1b5c9559312c1d",
|
"id": "6e072894aa1f5d9535a1127a0d7a7f8e65100a2c",
|
||||||
"network": "laconic_9000-1",
|
"network": "laconic_9000-1",
|
||||||
"moniker": "localtestnet"
|
"moniker": "localtestnet"
|
||||||
},
|
},
|
||||||
"sync": {
|
"sync": {
|
||||||
"latest_block_hash": "1BDF4CB9AE2390DA65BCF997C83133C18014FCDDCAE03708488F0B56FCEEA429",
|
"latestBlockHash": "260102C283D0411CFBA0270F7DC182650FFCA737A2F6F652A985F6065696F590",
|
||||||
"latest_block_height": "5",
|
"latestBlockHeight": "49",
|
||||||
"latest_block_time": "2023-08-09 16:00:30.386903172 +0000 UTC",
|
"latestBlockTime": "2024-07-25 06:14:05.626744215 +0000 UTC",
|
||||||
"catching_up": false
|
"catchingUp": false
|
||||||
},
|
},
|
||||||
"validator": {
|
"validator": {
|
||||||
"address": "651FBC700B747C76E90ACFC18CC9508C3D0905B9",
|
"address": "86970D950BC9C16F3991A52D9C6DC55BA478A7C6",
|
||||||
"voting_power": "1000000000000000"
|
"votingPower": "1000000000000000"
|
||||||
},
|
},
|
||||||
"validators": [
|
"validators": [
|
||||||
{
|
{
|
||||||
"address": "651FBC700B747C76E90ACFC18CC9508C3D0905B9",
|
"address": "86970D950BC9C16F3991A52D9C6DC55BA478A7C6",
|
||||||
"voting_power": "1000000000000000",
|
"votingPower": "1000000000000000",
|
||||||
"proposer_priority": "0"
|
"proposerPriority": "0"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"num_peers": "0",
|
"numPeers": "0",
|
||||||
"peers": [],
|
"peers": [],
|
||||||
"disk_usage": "292.0K"
|
"diskUsage": "688K"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -186,13 +186,13 @@ wns
|
|||||||
1. The following command will create a bond and publish a record:
|
1. The following command will create a bond and publish a record:
|
||||||
|
|
||||||
```
|
```
|
||||||
laconic-so --stack fixturenet-laconic-loaded deploy exec cli ./scripts/create-demo-records.sh
|
laconic-so deployment --dir laconic-loaded-deployment exec cli ./scripts/create-demo-records.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
You'll get an output like:
|
You'll get an output like:
|
||||||
|
|
||||||
```
|
```
|
||||||
Balance is: 99998999999999998999600000
|
Balance is: 9.9999e+25
|
||||||
Created bond with id: dd88e8d6f9567b32b28e70552aea4419c5dd3307ebae85a284d1fe38904e301a
|
Created bond with id: dd88e8d6f9567b32b28e70552aea4419c5dd3307ebae85a284d1fe38904e301a
|
||||||
Published demo-record-1.yml with id: bafyreierh3xnfivexlscdwubvczmddsnf46uytyfvrbdhkjzztvsz6ruly
|
Published demo-record-1.yml with id: bafyreierh3xnfivexlscdwubvczmddsnf46uytyfvrbdhkjzztvsz6ruly
|
||||||
```
|
```
|
||||||
@@ -223,5 +223,5 @@ record:
|
|||||||
- e.g,:
|
- e.g,:
|
||||||
|
|
||||||
```
|
```
|
||||||
laconic-so --stack fixturenet-laconic-loaded deploy exec cli "laconic cns record list"
|
laconic-so deployment --dir laconic-loaded-deployment exec cli "laconic registry record list"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|||||||
long_description = fh.read()
|
long_description = fh.read()
|
||||||
with open("requirements.txt", "r", encoding="utf-8") as fh:
|
with open("requirements.txt", "r", encoding="utf-8") as fh:
|
||||||
requirements = fh.read()
|
requirements = fh.read()
|
||||||
|
with open("stack_orchestrator/data/version.txt", "r", encoding="utf-8") as fh:
|
||||||
|
version = fh.readlines()[-1].strip(" \n")
|
||||||
setup(
|
setup(
|
||||||
name='laconic-stack-orchestrator',
|
name='laconic-stack-orchestrator',
|
||||||
version='1.0.12',
|
version=version,
|
||||||
author='Cerc',
|
author='Cerc',
|
||||||
author_email='info@cerc.io',
|
author_email='info@cerc.io',
|
||||||
license='GNU Affero General Public License',
|
license='GNU Affero General Public License',
|
||||||
|
|||||||
@@ -21,11 +21,6 @@ from stack_orchestrator.util import get_parsed_stack_config, warn_exit
|
|||||||
|
|
||||||
def get_containers_in_scope(stack: str):
|
def get_containers_in_scope(stack: str):
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
|
||||||
from stack_orchestrator import data
|
|
||||||
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
|
||||||
all_containers = container_list_file.read().splitlines()
|
|
||||||
|
|
||||||
containers_in_scope = []
|
containers_in_scope = []
|
||||||
if stack:
|
if stack:
|
||||||
stack_config = get_parsed_stack_config(stack)
|
stack_config = get_parsed_stack_config(stack)
|
||||||
@@ -33,7 +28,10 @@ def get_containers_in_scope(stack: str):
|
|||||||
warn_exit(f"stack {stack} does not define any containers")
|
warn_exit(f"stack {stack} does not define any containers")
|
||||||
containers_in_scope = stack_config['containers']
|
containers_in_scope = stack_config['containers']
|
||||||
else:
|
else:
|
||||||
containers_in_scope = all_containers
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
|
from stack_orchestrator import data
|
||||||
|
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
||||||
|
containers_in_scope = container_list_file.read().splitlines()
|
||||||
|
|
||||||
if opts.o.verbose:
|
if opts.o.verbose:
|
||||||
print(f'Containers: {containers_in_scope}')
|
print(f'Containers: {containers_in_scope}')
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ services:
|
|||||||
laconicd:
|
laconicd:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: cerc/laconicd:local
|
image: cerc/laconicd:local
|
||||||
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
command: ["bash", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||||
environment:
|
environment:
|
||||||
TEST_AUCTION_ENABLED: ${TEST_AUCTION_ENABLED}
|
TEST_AUCTION_ENABLED: ${TEST_AUCTION_ENABLED:-false}
|
||||||
TEST_REGISTRY_EXPIRY: ${TEST_REGISTRY_EXPIRY}
|
TEST_REGISTRY_EXPIRY: ${TEST_REGISTRY_EXPIRY:-false}
|
||||||
|
ONBOARDING_ENABLED: ${ONBOARDING_ENABLED:-false}
|
||||||
volumes:
|
volumes:
|
||||||
# The cosmos-sdk node's database directory:
|
# The cosmos-sdk node's database directory:
|
||||||
- laconicd-data:/root/.laconicd
|
- laconicd-data:/root/.laconicd
|
||||||
@@ -19,11 +20,9 @@ services:
|
|||||||
- "26657"
|
- "26657"
|
||||||
- "26656"
|
- "26656"
|
||||||
- "9473"
|
- "9473"
|
||||||
- "8545"
|
|
||||||
- "8546"
|
|
||||||
- "9090"
|
- "9090"
|
||||||
- "9091"
|
|
||||||
- "1317"
|
- "1317"
|
||||||
|
|
||||||
cli:
|
cli:
|
||||||
image: cerc/laconic-registry-cli:local
|
image: cerc/laconic-registry-cli:local
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
services:
|
||||||
|
laconic-explorer:
|
||||||
|
restart: unless-stopped
|
||||||
|
image: cerc/ping-pub:local
|
||||||
|
environment:
|
||||||
|
- LACONIC_LACONICD_API_URL=${LACONIC_LACONICD_API_URL:-http://localhost:1317}
|
||||||
|
- LACONIC_LACONICD_RPC_URL=${LACONIC_LACONICD_RPC_URL:-http://localhost:26657}
|
||||||
|
- LACONIC_LACONICD_CHAIN_ID=${LACONIC_LACONICD_CHAIN_ID:-chain-id-not-set}
|
||||||
|
ports:
|
||||||
|
- "5173"
|
||||||
@@ -4,5 +4,9 @@ services:
|
|||||||
ping-pub:
|
ping-pub:
|
||||||
image: cerc/ping-pub:local
|
image: cerc/ping-pub:local
|
||||||
restart: always
|
restart: always
|
||||||
|
environment:
|
||||||
|
LACONIC_LACONICD_CHAIN_ID: ${LACONIC_LACONICD_CHAIN_ID:-laconic_9000-1}
|
||||||
|
LACONIC_LACONICD_RPC_URL: ${LACONIC_LACONICD_RPC_URL:-http://localhost:26657}
|
||||||
|
LACONIC_LACONICD_API_URL: ${LACONIC_LACONICD_API_URL:-http://localhost:1317}
|
||||||
ports:
|
ports:
|
||||||
- "5173:5173"
|
- 5173
|
||||||
|
|||||||
@@ -8,68 +8,67 @@ KEY="mykey"
|
|||||||
CHAINID="laconic_9000-1"
|
CHAINID="laconic_9000-1"
|
||||||
MONIKER="localtestnet"
|
MONIKER="localtestnet"
|
||||||
KEYRING="test"
|
KEYRING="test"
|
||||||
KEYALGO="eth_secp256k1"
|
KEYALGO="secp256k1"
|
||||||
LOGLEVEL="info"
|
LOGLEVEL="${LOGLEVEL:-info}"
|
||||||
# trace evm
|
|
||||||
TRACE="--trace"
|
|
||||||
# TRACE=""
|
|
||||||
|
|
||||||
if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
||||||
# validate dependencies are installed
|
# validate dependencies are installed
|
||||||
command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; }
|
command -v jq > /dev/null 2>&1 || {
|
||||||
|
echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# remove existing daemon and client
|
# remove existing daemon and client
|
||||||
rm -rf $HOME/.laconicd/*
|
rm -rf $HOME/.laconicd/*
|
||||||
rm -rf $HOME/.laconic/*
|
|
||||||
|
|
||||||
if [ -n "`which make`" ]; then
|
if [ -n "`which make`" ]; then
|
||||||
make install
|
make install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
laconicd config keyring-backend $KEYRING
|
laconicd config set client chain-id $CHAINID
|
||||||
laconicd config chain-id $CHAINID
|
laconicd config set client keyring-backend $KEYRING
|
||||||
|
|
||||||
# if $KEY exists it should be deleted
|
# if $KEY exists it should be deleted
|
||||||
laconicd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO
|
laconicd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO
|
||||||
|
|
||||||
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
|
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
|
||||||
laconicd init $MONIKER --chain-id $CHAINID
|
laconicd init $MONIKER --chain-id $CHAINID --default-denom photon
|
||||||
|
|
||||||
# Change parameter token denominations to aphoton
|
update_genesis() {
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
jq "$1" $HOME/.laconicd/config/genesis.json > $HOME/.laconicd/config/tmp_genesis.json &&
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
}
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
|
||||||
# Custom modules
|
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["record_rent"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_rent"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_commit_fee"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_reveal_fee"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_minimum_bid"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
|
||||||
|
|
||||||
if [[ "$TEST_REGISTRY_EXPIRY" == "true" ]]; then
|
if [[ "$TEST_REGISTRY_EXPIRY" == "true" ]]; then
|
||||||
echo "Setting timers for expiry tests."
|
echo "Setting timers for expiry tests."
|
||||||
|
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["record_rent_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
update_genesis '.app_state["registry"]["params"]["record_rent_duration"]="60s"'
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_grace_period"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="60s"'
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_rent_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$TEST_AUCTION_ENABLED" == "true" ]]; then
|
if [[ "$TEST_AUCTION_ENABLED" == "true" ]]; then
|
||||||
echo "Enabling auction and setting timers."
|
echo "Enabling auction and setting timers."
|
||||||
|
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_enabled"]=true' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
update_genesis '.app_state["registry"]["params"]["authority_auction_enabled"]=true'
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_rent_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"'
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_grace_period"]="300s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="300s"'
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_commits_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
update_genesis '.app_state["registry"]["params"]["authority_auction_commits_duration"]="60s"'
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_reveals_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
update_genesis '.app_state["registry"]["params"]["authority_auction_reveals_duration"]="60s"'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$ONBOARDING_ENABLED" == "true" ]]; then
|
||||||
|
echo "Enabling validator onboarding."
|
||||||
|
|
||||||
|
update_genesis '.app_state["onboarding"]["params"]["onboarding_enabled"]=true'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# increase block time (?)
|
# increase block time (?)
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.consensus_params["block"]["time_iota_ms"]="1000"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
update_genesis '.consensus["params"]["block"]["time_iota_ms"]="1000"'
|
||||||
|
|
||||||
# Set gas limit in genesis
|
# Set gas limit in genesis
|
||||||
cat $HOME/.laconicd/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="10000000"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
update_genesis '.consensus["params"]["block"]["max_gas"]="10000000"'
|
||||||
|
|
||||||
# disable produce empty block
|
# disable produce empty block
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
@@ -78,30 +77,6 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
|||||||
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $1 == "pending" ]]; then
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
||||||
sed -i '' 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i '' 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i '' 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i '' 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i '' 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i '' 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i '' 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i '' 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
else
|
|
||||||
sed -i 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
sed -i 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME/.laconicd/config/config.toml
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Enable telemetry (prometheus metrics: http://localhost:1317/metrics?format=prometheus)
|
# Enable telemetry (prometheus metrics: http://localhost:1317/metrics?format=prometheus)
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
sed -i '' 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml
|
sed -i '' 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml
|
||||||
@@ -113,24 +88,30 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
|||||||
sed -i 's/prometheus = false/prometheus = true/g' $HOME/.laconicd/config/config.toml
|
sed -i 's/prometheus = false/prometheus = true/g' $HOME/.laconicd/config/config.toml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Run this to allow requests from any origin
|
||||||
|
sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $HOME/.laconicd/config/config.toml
|
||||||
|
sed -i 's/enabled-unsafe-cors.*$/enabled-unsafe-cors = true/' $HOME/.laconicd/config/app.toml
|
||||||
|
|
||||||
# Allocate genesis accounts (cosmos formatted addresses)
|
# Allocate genesis accounts (cosmos formatted addresses)
|
||||||
laconicd add-genesis-account $KEY 100000000000000000000000000aphoton --keyring-backend $KEYRING
|
laconicd genesis add-genesis-account $KEY 100000000000000000000000000photon --keyring-backend $KEYRING
|
||||||
|
|
||||||
# Sign genesis transaction
|
# Sign genesis transaction
|
||||||
laconicd gentx $KEY 1000000000000000000000aphoton --keyring-backend $KEYRING --chain-id $CHAINID
|
laconicd genesis gentx $KEY 1000000000000000000000photon --keyring-backend $KEYRING --chain-id $CHAINID
|
||||||
|
|
||||||
# Collect genesis tx
|
# Collect genesis tx
|
||||||
laconicd collect-gentxs
|
laconicd genesis collect-gentxs
|
||||||
|
|
||||||
# Run this to ensure everything worked and that the genesis file is setup correctly
|
# Run this to ensure everything worked and that the genesis file is setup correctly
|
||||||
laconicd validate-genesis
|
laconicd genesis validate
|
||||||
|
|
||||||
if [[ $1 == "pending" ]]; then
|
|
||||||
echo "pending mode is on, please wait for the first block committed."
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "Using existing database at $HOME/.laconicd. To replace, run '`basename $0` clean'"
|
echo "Using existing database at $HOME/.laconicd. To replace, run '`basename $0` clean'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
||||||
laconicd start --pruning=nothing --evm.tracer=json $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --gql-server --gql-playground
|
laconicd start \
|
||||||
|
--pruning=nothing \
|
||||||
|
--log_level $LOGLEVEL \
|
||||||
|
--minimum-gas-prices=0.0001photon \
|
||||||
|
--api.enable \
|
||||||
|
--rpc.laddr="tcp://0.0.0.0:26657" \
|
||||||
|
--gql-server --gql-playground
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
services:
|
services:
|
||||||
cns:
|
registry:
|
||||||
restEndpoint: 'http://laconicd:1317'
|
rpcEndpoint: 'http://laconicd:26657'
|
||||||
gqlEndpoint: 'http://laconicd:9473/api'
|
gqlEndpoint: 'http://laconicd:9473/api'
|
||||||
userKey: REPLACE_WITH_MYKEY
|
userKey: REPLACE_WITH_MYKEY
|
||||||
bondId:
|
bondId:
|
||||||
chainId: laconic_9000-1
|
chainId: laconic_9000-1
|
||||||
gas: 350000
|
gas: 350000
|
||||||
fees: 200000aphoton
|
fees: 200000photon
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
services:
|
services:
|
||||||
cns:
|
registry:
|
||||||
restEndpoint: 'http://laconicd:1317'
|
rpcEndpoint: 'http://laconicd:26657'
|
||||||
gqlEndpoint: 'http://laconicd:9473/api'
|
gqlEndpoint: 'http://laconicd:9473/api'
|
||||||
userKey: REPLACE_WITH_MYKEY
|
userKey: REPLACE_WITH_MYKEY
|
||||||
bondId:
|
bondId:
|
||||||
chainId: laconic_9000-1
|
chainId: laconic_9000-1
|
||||||
gas: 250000
|
gas: 250000
|
||||||
fees: 200000aphoton
|
fees: 200000photon
|
||||||
|
|||||||
@@ -4,15 +4,12 @@ if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#TODO: pass these in from the caller
|
#TODO: pass these in from the caller
|
||||||
TRACE="--trace"
|
|
||||||
LOGLEVEL="info"
|
LOGLEVEL="info"
|
||||||
|
|
||||||
laconicd start \
|
laconicd start \
|
||||||
--pruning=nothing \
|
--pruning=nothing \
|
||||||
--evm.tracer=json $TRACE \
|
|
||||||
--log_level $LOGLEVEL \
|
--log_level $LOGLEVEL \
|
||||||
--minimum-gas-prices=0.0001aphoton \
|
--minimum-gas-prices=0.0001photon \
|
||||||
--json-rpc.api eth,txpool,personal,net,debug,web3,miner \
|
|
||||||
--api.enable \
|
--api.enable \
|
||||||
--gql-server \
|
--gql-server \
|
||||||
--gql-playground
|
--gql-playground
|
||||||
|
|||||||
@@ -68,5 +68,5 @@ ENV PATH="${PATH}:/scripts"
|
|||||||
COPY entrypoint.sh .
|
COPY entrypoint.sh .
|
||||||
ENTRYPOINT ["./entrypoint.sh"]
|
ENTRYPOINT ["./entrypoint.sh"]
|
||||||
# Placeholder CMD : generally this will be overridden at run time like :
|
# Placeholder CMD : generally this will be overridden at run time like :
|
||||||
# docker run -it -v /home/builder/cerc/laconic-sdk:/workspace cerc/builder-js sh -c 'cd /workspace && yarn && yarn build'
|
# docker run -it -v /home/builder/cerc/registry-sdk:/workspace cerc/builder-js sh -c 'cd /workspace && yarn && yarn build'
|
||||||
CMD node --version
|
CMD node --version
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Build cerc/laconic-registry-cli
|
# Build cerc/laconic-console-host
|
||||||
|
|
||||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -5,16 +5,16 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
registry_command="laconic cns"
|
registry_command="laconic registry"
|
||||||
demo_records_dir="scripts/demo-records"
|
demo_records_dir="scripts/demo-records"
|
||||||
|
|
||||||
# Check we have funds
|
# Check we have funds
|
||||||
funds_response=$(${registry_command} account get --address $(cat my-address.txt))
|
funds_response=$(${registry_command} account get --address $(cat my-address.txt))
|
||||||
funds_balance=$(echo ${funds_response} | jq -r .[0].balance[0].quantity)
|
funds_balance=$(echo ${funds_response} | jq -r ".[0].balance[0].quantity")
|
||||||
echo "Balance is: ${funds_balance}"
|
echo "Balance is: ${funds_balance}"
|
||||||
|
|
||||||
# Create a bond
|
# Create a bond
|
||||||
bond_create_result=$(${registry_command} bond create --type aphoton --quantity 1000000000)
|
bond_create_result=$(${registry_command} bond create --type photon --quantity 1000000000)
|
||||||
bond_id=$(echo ${bond_create_result} | jq -r .bondId)
|
bond_id=$(echo ${bond_create_result} | jq -r .bondId)
|
||||||
echo "Created bond with id: ${bond_id}"
|
echo "Created bond with id: ${bond_id}"
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -7,9 +7,9 @@ record:
|
|||||||
env:
|
env:
|
||||||
ENV_VAR_A: A
|
ENV_VAR_A: A
|
||||||
ENV_VAR_B: B
|
ENV_VAR_B: B
|
||||||
crn:
|
lrn:
|
||||||
- crn://foo.bar
|
- lrn://foo.bar
|
||||||
- crn://bar.baz
|
- lrn://bar.baz
|
||||||
meta:
|
meta:
|
||||||
foo: bar
|
foo: bar
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ RUN \
|
|||||||
&& su ${USERNAME} -c "umask 0002 && npm install -g semver" \
|
&& su ${USERNAME} -c "umask 0002 && npm install -g semver" \
|
||||||
# Install pnpm
|
# Install pnpm
|
||||||
&& su ${USERNAME} -c "umask 0002 && npm install -g pnpm" \
|
&& su ${USERNAME} -c "umask 0002 && npm install -g pnpm" \
|
||||||
|
# Install bun
|
||||||
|
&& su ${USERNAME} -c "umask 0002 && npm install -g bun@1.1.x" \
|
||||||
&& npm cache clean --force > /dev/null 2>&1
|
&& npm cache clean --force > /dev/null 2>&1
|
||||||
|
|
||||||
# [Optional] Uncomment this section to install additional OS packages.
|
# [Optional] Uncomment this section to install additional OS packages.
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ if [ -z "$CERC_BUILD_TOOL" ]; then
|
|||||||
CERC_BUILD_TOOL=pnpm
|
CERC_BUILD_TOOL=pnpm
|
||||||
elif [ -f "yarn.lock" ]; then
|
elif [ -f "yarn.lock" ]; then
|
||||||
CERC_BUILD_TOOL=yarn
|
CERC_BUILD_TOOL=yarn
|
||||||
|
elif [ -f "bun.lockb" ]; then
|
||||||
|
CERC_BUILD_TOOL=bun
|
||||||
else
|
else
|
||||||
CERC_BUILD_TOOL=npm
|
CERC_BUILD_TOOL=npm
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -5,14 +5,19 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
CERC_MIN_NEXTVER=13.4.2
|
CERC_MIN_NEXTVER=13.4.2
|
||||||
|
CERC_DEFAULT_WEBPACK_VER="5.93.0"
|
||||||
|
|
||||||
CERC_NEXT_VERSION="${CERC_NEXT_VERSION:-keep}"
|
CERC_NEXT_VERSION="${CERC_NEXT_VERSION:-keep}"
|
||||||
|
CERC_WEBPACK_VERSION="${CERC_WEBPACK_VERSION:-keep}"
|
||||||
|
|
||||||
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
CERC_BUILD_TOOL="${CERC_BUILD_TOOL}"
|
||||||
if [ -z "$CERC_BUILD_TOOL" ]; then
|
if [ -z "$CERC_BUILD_TOOL" ]; then
|
||||||
if [ -f "pnpm-lock.yaml" ]; then
|
if [ -f "pnpm-lock.yaml" ]; then
|
||||||
CERC_BUILD_TOOL=pnpm
|
CERC_BUILD_TOOL=pnpm
|
||||||
elif [ -f "yarn.lock" ]; then
|
elif [ -f "yarn.lock" ]; then
|
||||||
CERC_BUILD_TOOL=yarn
|
CERC_BUILD_TOOL=yarn
|
||||||
|
elif [ -f "bun.lockb" ]; then
|
||||||
|
CERC_BUILD_TOOL=bun
|
||||||
else
|
else
|
||||||
CERC_BUILD_TOOL=npm
|
CERC_BUILD_TOOL=npm
|
||||||
fi
|
fi
|
||||||
@@ -23,13 +28,21 @@ WORK_DIR="${1:-/app}"
|
|||||||
|
|
||||||
cd "${WORK_DIR}" || exit 1
|
cd "${WORK_DIR}" || exit 1
|
||||||
|
|
||||||
|
if [ -f "next.config.mjs" ]; then
|
||||||
|
NEXT_CONFIG_JS="next.config.mjs"
|
||||||
|
IMPORT_OR_REQUIRE="import"
|
||||||
|
else
|
||||||
|
NEXT_CONFIG_JS="next.config.js"
|
||||||
|
IMPORT_OR_REQUIRE="require"
|
||||||
|
fi
|
||||||
|
|
||||||
# If this file doesn't exist at all, we'll get errors below.
|
# If this file doesn't exist at all, we'll get errors below.
|
||||||
if [ ! -f "next.config.js" ]; then
|
if [ ! -f "${NEXT_CONFIG_JS}" ]; then
|
||||||
touch next.config.js
|
touch ${NEXT_CONFIG_JS}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "next.config.dist" ]; then
|
if [ ! -f "next.config.dist" ]; then
|
||||||
cp next.config.js next.config.dist
|
cp $NEXT_CONFIG_JS next.config.dist
|
||||||
fi
|
fi
|
||||||
|
|
||||||
which js-beautify >/dev/null
|
which js-beautify >/dev/null
|
||||||
@@ -37,17 +50,34 @@ if [ $? -ne 0 ]; then
|
|||||||
npm i -g js-beautify
|
npm i -g js-beautify
|
||||||
fi
|
fi
|
||||||
|
|
||||||
js-beautify next.config.dist > next.config.js
|
# js-beautify formats NEXTJS_CONFIG_FILE (ie next.config.js / next.config.mjs) so we can reliably transformable later
|
||||||
echo "" >> next.config.js
|
js-beautify next.config.dist > ${NEXT_CONFIG_JS}
|
||||||
|
echo "" >> ${NEXT_CONFIG_JS}
|
||||||
|
|
||||||
WEBPACK_REQ_LINE=$(grep -n "require([\'\"]webpack[\'\"])" next.config.js | cut -d':' -f1)
|
if [ "${IMPORT_OR_REQUIRE}" == "require" ]; then
|
||||||
if [ -z "$WEBPACK_REQ_LINE" ]; then
|
WEBPACK_REQ_LINE=$(grep -n "require([\'\"]webpack[\'\"])" ${NEXT_CONFIG_JS} | cut -d':' -f1)
|
||||||
cat > next.config.js.0 <<EOF
|
if [ -z "$WEBPACK_REQ_LINE" ]; then
|
||||||
|
cat > ${NEXT_CONFIG_JS}.0 <<EOF
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
WEBPACK_IMPORT_LINE=$(grep -n "^import .*[\'\"]webpack[\'\"];?$" ${NEXT_CONFIG_JS} | cut -d':' -f1)
|
||||||
|
if [ -z "$WEBPACK_IMPORT_LINE" ]; then
|
||||||
|
cat > ${NEXT_CONFIG_JS}.0 <<EOF
|
||||||
|
import webpack from 'webpack';
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
CREATE_REQUIRE_LINE=$(grep -n "require = createRequire" ${NEXT_CONFIG_JS} | cut -d':' -f1)
|
||||||
|
if [ -z "$CREATE_REQUIRE_LINE" ]; then
|
||||||
|
cat >> ${NEXT_CONFIG_JS}.0 <<EOF
|
||||||
|
import { createRequire } from "module";
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat > next.config.js.1 <<EOF
|
cat > ${NEXT_CONFIG_JS}.1 <<EOF
|
||||||
let envMap;
|
let envMap;
|
||||||
try {
|
try {
|
||||||
// .env-list.json provides us a list of identifiers which should be replaced at runtime.
|
// .env-list.json provides us a list of identifiers which should be replaced at runtime.
|
||||||
@@ -55,7 +85,8 @@ try {
|
|||||||
a[v] = \`"CERC_RUNTIME_ENV_\${v.split(/\./).pop()}"\`;
|
a[v] = \`"CERC_RUNTIME_ENV_\${v.split(/\./).pop()}"\`;
|
||||||
return a;
|
return a;
|
||||||
}, {});
|
}, {});
|
||||||
} catch {
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
// If .env-list.json cannot be loaded, we are probably running in dev mode, so use process.env instead.
|
// If .env-list.json cannot be loaded, we are probably running in dev mode, so use process.env instead.
|
||||||
envMap = Object.keys(process.env).reduce((a, v) => {
|
envMap = Object.keys(process.env).reduce((a, v) => {
|
||||||
if (v.startsWith('CERC_')) {
|
if (v.startsWith('CERC_')) {
|
||||||
@@ -64,40 +95,80 @@ try {
|
|||||||
return a;
|
return a;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
console.log(envMap);
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
CONFIG_LINES=$(wc -l next.config.js | awk '{ print $1 }')
|
grep 'withPWA' ${NEXT_CONFIG_JS} >/dev/null && HAS_WITHPWA=true || HAS_WITHPWA=false
|
||||||
ENV_LINE=$(grep -n 'env:' next.config.js | cut -d':' -f1)
|
|
||||||
WEBPACK_CONF_LINE=$(egrep -n 'webpack:\s+\([^,]+,' next.config.js | cut -d':' -f1)
|
|
||||||
NEXT_SECTION_ADJUSTMENT=0
|
|
||||||
|
|
||||||
if [ -n "$WEBPACK_CONF_LINE" ]; then
|
if [ "$HAS_WITHPWA" == "true" ]; then
|
||||||
WEBPACK_CONF_VAR=$(egrep -n 'webpack:\s+\([^,]+,' next.config.js | cut -d',' -f1 | cut -d'(' -f2)
|
if [ "$IMPORT_OR_REQUIRE" == "import" ]; then
|
||||||
head -$(( ${WEBPACK_CONF_LINE} )) next.config.js > next.config.js.2
|
cat > ${NEXT_CONFIG_JS}.2 <<EOF
|
||||||
cat > next.config.js.3 <<EOF
|
const __xPWA__ = (p) => {
|
||||||
$WEBPACK_CONF_VAR.plugins.push(new webpack.DefinePlugin(envMap));
|
const realPWA = withPWA(p);
|
||||||
EOF
|
return (nextConfig) => {
|
||||||
NEXT_SECTION_LINE=$((WEBPACK_CONF_LINE))
|
const modConfig = {...nextConfig};
|
||||||
elif [ -n "$ENV_LINE" ]; then
|
|
||||||
head -$(( ${ENV_LINE} - 1 )) next.config.js > next.config.js.2
|
modConfig.webpack = (config) => {
|
||||||
cat > next.config.js.3 <<EOF
|
|
||||||
webpack: (config) => {
|
|
||||||
config.plugins.push(new webpack.DefinePlugin(envMap));
|
config.plugins.push(new webpack.DefinePlugin(envMap));
|
||||||
return config;
|
return nextConfig.webpack ? nextConfig.webpack(config) : config;
|
||||||
},
|
};
|
||||||
|
|
||||||
|
return realPWA(modConfig);
|
||||||
|
};
|
||||||
|
};
|
||||||
EOF
|
EOF
|
||||||
NEXT_SECTION_ADJUSTMENT=1
|
else
|
||||||
NEXT_SECTION_LINE=$ENV_LINE
|
cat > ${NEXT_CONFIG_JS}.3 <<EOF
|
||||||
|
const __xPWA__ = (nextConfig) => {
|
||||||
|
const modConfig = {...nextConfig};
|
||||||
|
|
||||||
|
modConfig.webpack = (config) => {
|
||||||
|
config.plugins.push(new webpack.DefinePlugin(envMap));
|
||||||
|
return nextConfig.webpack ? nextConfig.webpack(config) : config;
|
||||||
|
};
|
||||||
|
|
||||||
|
return withPWA(modConfig);
|
||||||
|
};
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat ${NEXT_CONFIG_JS} | js-beautify | sed 's/withPWA(/__xPWA__(/g' > ${NEXT_CONFIG_JS}.4
|
||||||
else
|
else
|
||||||
echo "WARNING: Cannot find location to insert environment variable map in next.config.js" 1>&2
|
cat > ${NEXT_CONFIG_JS}.3 <<EOF
|
||||||
rm -f next.config.js.*
|
const __xCfg__ = (nextConfig) => {
|
||||||
NEXT_SECTION_LINE=0
|
const modConfig = {...nextConfig};
|
||||||
|
|
||||||
|
modConfig.webpack = (config) => {
|
||||||
|
config.plugins.push(new webpack.DefinePlugin(envMap));
|
||||||
|
return nextConfig.webpack ? nextConfig.webpack(config) : config;
|
||||||
|
};
|
||||||
|
|
||||||
|
return modConfig;
|
||||||
|
};
|
||||||
|
EOF
|
||||||
|
if [ "$IMPORT_OR_REQUIRE" == "import" ]; then
|
||||||
|
cat ${NEXT_CONFIG_JS} | js-beautify | sed 's/export\s\+default\s\+/const __orig_cfg__ = /g' > ${NEXT_CONFIG_JS}.4
|
||||||
|
echo "export default __xCfg__(__orig_cfg__);" > ${NEXT_CONFIG_JS}.5
|
||||||
|
else
|
||||||
|
cat ${NEXT_CONFIG_JS} | js-beautify | sed 's/module.exports\s\+=\s\+/const __orig_cfg__ = /g' > ${NEXT_CONFIG_JS}.4
|
||||||
|
echo "module.exports = __xCfg__(__orig_cfg__);" > ${NEXT_CONFIG_JS}.5
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tail -$(( ${CONFIG_LINES} - ${NEXT_SECTION_LINE} + ${NEXT_SECTION_ADJUSTMENT} )) next.config.js > next.config.js.5
|
|
||||||
|
|
||||||
cat next.config.js.* | sed 's/^ *//g' | js-beautify | grep -v 'process\.\env\.' | js-beautify > next.config.js
|
rm -f ${NEXT_CONFIG_JS}
|
||||||
rm next.config.js.*
|
for ((i=0; i <= 10; i++)); do
|
||||||
|
if [ -s "${NEXT_CONFIG_JS}.${i}" ]; then
|
||||||
|
if [ $i -le 2 ] ; then
|
||||||
|
cat ${NEXT_CONFIG_JS}.${i} >> ${NEXT_CONFIG_JS}
|
||||||
|
else
|
||||||
|
cat ${NEXT_CONFIG_JS}.${i} | sed 's/^ *//g' | js-beautify | grep -v 'process\.\env\.' | js-beautify >> ${NEXT_CONFIG_JS}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm ${NEXT_CONFIG_JS}.*
|
||||||
|
cat ${NEXT_CONFIG_JS} | js-beautify > ${NEXT_CONFIG_JS}.pretty
|
||||||
|
mv ${NEXT_CONFIG_JS}.pretty ${NEXT_CONFIG_JS}
|
||||||
|
|
||||||
"${SCRIPT_DIR}/find-env.sh" "$(pwd)" > .env-list.json
|
"${SCRIPT_DIR}/find-env.sh" "$(pwd)" > .env-list.json
|
||||||
|
|
||||||
@@ -105,8 +176,6 @@ if [ ! -f "package.dist" ]; then
|
|||||||
cp package.json package.dist
|
cp package.json package.dist
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat package.dist | jq '.scripts.cerc_compile = "next experimental-compile"' | jq '.scripts.cerc_generate = "next experimental-generate"' > package.json
|
|
||||||
|
|
||||||
CUR_NEXT_VERSION="`jq -r '.dependencies.next' package.json`"
|
CUR_NEXT_VERSION="`jq -r '.dependencies.next' package.json`"
|
||||||
|
|
||||||
if [ "$CERC_NEXT_VERSION" != "keep" ] && [ "$CUR_NEXT_VERSION" != "$CERC_NEXT_VERSION" ]; then
|
if [ "$CERC_NEXT_VERSION" != "keep" ] && [ "$CUR_NEXT_VERSION" != "$CERC_NEXT_VERSION" ]; then
|
||||||
@@ -115,10 +184,38 @@ if [ "$CERC_NEXT_VERSION" != "keep" ] && [ "$CUR_NEXT_VERSION" != "$CERC_NEXT_VE
|
|||||||
mv package.json.$$ package.json
|
mv package.json.$$ package.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
CUR_WEBPACK_VERSION="`jq -r '.dependencies.webpack' package.json`"
|
||||||
|
if [ -z "$CUR_WEBPACK_VERSION" ]; then
|
||||||
|
CUR_WEBPACK_VERSION="`jq -r '.devDependencies.webpack' package.json`"
|
||||||
|
fi
|
||||||
|
if [ "${CERC_WEBPACK_VERSION}" != "keep" ] || [ "${CUR_WEBPACK_VERSION}" == "null" ]; then
|
||||||
|
if [ -z "$CERC_WEBPACK_VERSION" ] || [ "$CERC_WEBPACK_VERSION" == "keep" ]; then
|
||||||
|
CERC_WEBPACK_VERSION="${CERC_DEFAULT_WEBPACK_VER}"
|
||||||
|
fi
|
||||||
|
echo "Webpack is required for env variable substitution. Adding to webpack@$CERC_WEBPACK_VERSION to dependencies..." 1>&2
|
||||||
|
cat package.json | jq ".dependencies.webpack = \"$CERC_WEBPACK_VERSION\"" > package.json.$$
|
||||||
|
mv package.json.$$ package.json
|
||||||
|
fi
|
||||||
|
|
||||||
time $CERC_BUILD_TOOL install || exit 1
|
time $CERC_BUILD_TOOL install || exit 1
|
||||||
|
|
||||||
CUR_NEXT_VERSION=`jq -r '.version' node_modules/next/package.json`
|
CUR_NEXT_VERSION=`jq -r '.version' node_modules/next/package.json`
|
||||||
|
|
||||||
|
# See https://github.com/vercel/next.js/discussions/46544
|
||||||
|
semver -p -r ">=14.2.0" "$CUR_NEXT_VERSION"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
# For >= 14.2.0
|
||||||
|
CERC_NEXT_COMPILE_COMMAND="next build --experimental-build-mode compile"
|
||||||
|
CERC_NEXT_GENERATE_COMMAND="next build --experimental-build-mode generate"
|
||||||
|
else
|
||||||
|
# For 13.4.2 to 14.1.x
|
||||||
|
CERC_NEXT_COMPILE_COMMAND="next experimental-compile"
|
||||||
|
CERC_NEXT_GENERATE_COMMAND="next experimental-generate"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat package.json | jq ".scripts.cerc_compile = \"$CERC_NEXT_COMPILE_COMMAND\"" | jq ".scripts.cerc_generate = \"$CERC_NEXT_GENERATE_COMMAND\"" > package.json.$$
|
||||||
|
mv package.json.$$ package.json
|
||||||
|
|
||||||
semver -p -r ">=$CERC_MIN_NEXTVER" $CUR_NEXT_VERSION
|
semver -p -r ">=$CERC_MIN_NEXTVER" $CUR_NEXT_VERSION
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ for d in $(find . -maxdepth 1 -type d | grep -v '\./\.' | grep '/' | cut -d'/' -
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
NEXT_CONF="next.config.js next.config.dist"
|
NEXT_CONF="next.config.mjs next.config.js next.config.dist"
|
||||||
for f in $NEXT_CONF; do
|
for f in $NEXT_CONF; do
|
||||||
cat "$f" | tr -s '[:blank:]' '\n' | tr -s '[{},()]' '\n' | egrep -o 'process.env.[A-Za-z0-9_]+' >> $TMPF
|
if [ -f "$f" ]; then
|
||||||
|
cat "$f" | tr -s '[:blank:]' '\n' | tr -s '[{},()]' '\n' | egrep -o 'process.env.[A-Za-z0-9_]+' >> $TMPF
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
cat $TMPF | sort -u | jq --raw-input . | jq --slurp .
|
cat $TMPF | sort -u | jq --raw-input . | jq --slurp .
|
||||||
|
|||||||
+3
-1
@@ -5,7 +5,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
CERC_MAX_GENERATE_TIME=${CERC_MAX_GENERATE_TIME:-60}
|
CERC_MAX_GENERATE_TIME=${CERC_MAX_GENERATE_TIME:-120}
|
||||||
tpid=""
|
tpid=""
|
||||||
|
|
||||||
ctrl_c() {
|
ctrl_c() {
|
||||||
@@ -20,6 +20,8 @@ if [ -z "$CERC_BUILD_TOOL" ]; then
|
|||||||
CERC_BUILD_TOOL=pnpm
|
CERC_BUILD_TOOL=pnpm
|
||||||
elif [ -f "yarn.lock" ]; then
|
elif [ -f "yarn.lock" ]; then
|
||||||
CERC_BUILD_TOOL=yarn
|
CERC_BUILD_TOOL=yarn
|
||||||
|
elif [ -f "bun.lockb" ]; then
|
||||||
|
CERC_BUILD_TOOL=bun
|
||||||
else
|
else
|
||||||
CERC_BUILD_TOOL=npm
|
CERC_BUILD_TOOL=npm
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
FROM cerc/ping-pub-base:local
|
||||||
|
|
||||||
|
COPY ./scripts/update-explorer-config.sh /scripts
|
||||||
|
COPY ./scripts/start-serving-explorer.sh /scripts
|
||||||
|
COPY ./config/laconic-chaindata-template.json /config/chains/laconic-chaindata-template.json
|
||||||
|
|
||||||
|
EXPOSE 5173
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
CMD ["/scripts/start-serving-explorer.sh"]
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
FROM cerc/webapp-base:local
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN yarn
|
||||||
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Build the ping pub image
|
# Build the ping pub image
|
||||||
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
docker build -t cerc/ping-pub:local ${build_command_args} -f $CERC_REPO_BASE_DIR/explorer/Dockerfile $CERC_REPO_BASE_DIR/explorer
|
# Two-stage build is to allow us to pick up both the upstream repo's files, and local files here for config
|
||||||
|
docker build -t cerc/ping-pub-base:local ${build_command_args} -f $SCRIPT_DIR/Dockerfile.base $CERC_REPO_BASE_DIR/explorer
|
||||||
|
docker build -t cerc/ping-pub:local ${build_command_args} -f $SCRIPT_DIR/Dockerfile $SCRIPT_DIR
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"chain_name": "LACONIC_LACONICD_CHAIN_ID",
|
||||||
|
"registry_name": "LACONIC_LACONICD_CHAIN_ID",
|
||||||
|
"api": [
|
||||||
|
{"provider": "LX-one-tree-one-seven", "address": "LACONIC_LACONICD_API_URL"}
|
||||||
|
],
|
||||||
|
"rpc": [
|
||||||
|
{"provider": "LX-tendermint-rpc", "address": "LACONIC_LACONICD_RPC_URL"}
|
||||||
|
],
|
||||||
|
"sdk_version": "0.45.1",
|
||||||
|
"coin_type": "118",
|
||||||
|
"min_tx_fee": "800",
|
||||||
|
"addr_prefix": "ethm",
|
||||||
|
"logo": "/logos/cosmos.svg",
|
||||||
|
"assets": [{
|
||||||
|
"base": "photon",
|
||||||
|
"symbol": "LNT",
|
||||||
|
"exponent": "6",
|
||||||
|
"coingecko_id": "cosmos",
|
||||||
|
"logo": "/logos/cosmos.svg"
|
||||||
|
}]
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
${SCRIPT_DIR}/update-explorer-config.sh
|
||||||
|
|
||||||
|
echo "Starting serving explorer"
|
||||||
|
# Force cache re-build because vite is dumb and can't be restarted otherwise
|
||||||
|
yarn serve --host --force
|
||||||
+57
@@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify that we have the config variables we need
|
||||||
|
if [[ -z ${LACONIC_LACONICD_API_URL} ]]; then
|
||||||
|
echo "Error: LACONIC_LACONICD_API_URL not defined"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ -z ${LACONIC_LACONICD_RPC_URL} ]]; then
|
||||||
|
echo "Error: LACONIC_LACONICD_RPC_URL not defined"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ -z ${LACONIC_LACONICD_CHAIN_ID} ]]; then
|
||||||
|
echo "Error: LACONIC_LACONICD_CHAIN_ID not defined"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ping-pub explorer has endlessly confusing behavior where it
|
||||||
|
# infers the directory from which to load chain configuration files
|
||||||
|
# by the presence or absense of the substring "testnet" in the host name
|
||||||
|
# (browser side -- the host name of the host in the address bar of the browser)
|
||||||
|
# Accordingly we configure our network in both directories in order to
|
||||||
|
# subvert this lunacy.
|
||||||
|
explorer_mainnet_config_dir=/app/chains/mainnet
|
||||||
|
explorer_testnet_config_dir=/app/chains/testnet
|
||||||
|
|
||||||
|
# Create required directories
|
||||||
|
mkdir -p $explorer_mainnet_config_dir
|
||||||
|
mkdir -p $explorer_testnet_config_dir
|
||||||
|
|
||||||
|
config_template_file=/config/chains/laconic-chaindata-template.json
|
||||||
|
chain_config_name=laconic.json
|
||||||
|
mainnet_config_file=${explorer_mainnet_config_dir}/${chain_config_name}
|
||||||
|
testnet_config_file=${explorer_testnet_config_dir}/${chain_config_name}
|
||||||
|
|
||||||
|
# Delete the stock config files
|
||||||
|
rm -f ${explorer_testnet_config_dir}/*
|
||||||
|
rm -f ${explorer_mainnet_config_dir}/*
|
||||||
|
|
||||||
|
# Copy in our template file
|
||||||
|
cp ${config_template_file} ${mainnet_config_file}
|
||||||
|
|
||||||
|
# Update the file with the config variables
|
||||||
|
sed -i "s#LACONIC_LACONICD_API_URL#${LACONIC_LACONICD_API_URL}#g" ${mainnet_config_file}
|
||||||
|
sed -i "s#LACONIC_LACONICD_RPC_URL#${LACONIC_LACONICD_RPC_URL}#g" ${mainnet_config_file}
|
||||||
|
sed -i "s#LACONIC_LACONICD_CHAIN_ID#${LACONIC_LACONICD_CHAIN_ID}#g" ${mainnet_config_file}
|
||||||
|
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
echo "Updated chaindata file:"
|
||||||
|
cat ${mainnet_config_file}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy over to the testnet directory
|
||||||
|
cp ${mainnet_config_file} ${testnet_config_file}
|
||||||
@@ -28,6 +28,8 @@ RUN \
|
|||||||
&& su ${USERNAME} -c "umask 0002 && npm install -g semver" \
|
&& su ${USERNAME} -c "umask 0002 && npm install -g semver" \
|
||||||
# Install pnpm
|
# Install pnpm
|
||||||
&& su ${USERNAME} -c "umask 0002 && npm install -g pnpm" \
|
&& su ${USERNAME} -c "umask 0002 && npm install -g pnpm" \
|
||||||
|
# Install bun
|
||||||
|
&& su ${USERNAME} -c "umask 0002 && npm install -g bun@1.1.x" \
|
||||||
&& npm cache clean --force > /dev/null 2>&1
|
&& npm cache clean --force > /dev/null 2>&1
|
||||||
|
|
||||||
# [Optional] Uncomment this section to install additional OS packages.
|
# [Optional] Uncomment this section to install additional OS packages.
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# TODO: document what this script does
|
||||||
|
|
||||||
WORK_DIR="${1:-./}"
|
WORK_DIR="${1:-./}"
|
||||||
|
|
||||||
cd "${WORK_DIR}" || exit 1
|
cd "${WORK_DIR}" || exit 1
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ elif [ -f "${WORK_DIR}/package.json" ]; then
|
|||||||
CERC_BUILD_TOOL=pnpm
|
CERC_BUILD_TOOL=pnpm
|
||||||
elif [ -f "yarn.lock" ]; then
|
elif [ -f "yarn.lock" ]; then
|
||||||
CERC_BUILD_TOOL=yarn
|
CERC_BUILD_TOOL=yarn
|
||||||
|
elif [ -f "bun.lockb" ]; then
|
||||||
|
CERC_BUILD_TOOL=bun
|
||||||
else
|
else
|
||||||
CERC_BUILD_TOOL=npm
|
CERC_BUILD_TOOL=npm
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
laconic-sdk
|
registry-sdk
|
||||||
laconic-registry-cli
|
laconic-registry-cli
|
||||||
laconic-console
|
laconic-console
|
||||||
debug
|
debug
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ github.com/cerc-io/ipld-eth-db-validator
|
|||||||
github.com/cerc-io/ipld-eth-beacon-indexer
|
github.com/cerc-io/ipld-eth-beacon-indexer
|
||||||
github.com/cerc-io/ipld-eth-beacon-db
|
github.com/cerc-io/ipld-eth-beacon-db
|
||||||
github.com/cerc-io/laconicd
|
github.com/cerc-io/laconicd
|
||||||
github.com/cerc-io/laconic-sdk
|
github.com/cerc-io/registry-sdk
|
||||||
github.com/cerc-io/laconic-registry-cli
|
github.com/cerc-io/laconic-registry-cli
|
||||||
github.com/cerc-io/laconic-console
|
github.com/cerc-io/laconic-console
|
||||||
github.com/cerc-io/mobymask-watcher-ts
|
github.com/cerc-io/mobymask-watcher-ts
|
||||||
|
|||||||
@@ -58,5 +58,5 @@ Now npm packages can be built:
|
|||||||
Ensure that `CERC_NPM_AUTH_TOKEN` is set with the token printed above when the package-registry stack was deployed (the actual token value will be different than shown in this example):
|
Ensure that `CERC_NPM_AUTH_TOKEN` is set with the token printed above when the package-registry stack was deployed (the actual token value will be different than shown in this example):
|
||||||
```
|
```
|
||||||
$ export CERC_NPM_AUTH_TOKEN=84fe66a73698bf11edbdccd0a338236b7d1d5c45
|
$ export CERC_NPM_AUTH_TOKEN=84fe66a73698bf11edbdccd0a338236b7d1d5c45
|
||||||
$ laconic-so build-npms --include laconic-sdk,laconic-registry-cli
|
$ laconic-so build-npms --include registry-sdk,laconic-registry-cli
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ $ laconic-so --stack fixturenet-laconic-loaded deploy logs
|
|||||||
```
|
```
|
||||||
## 6. Test with the Registry CLI
|
## 6. Test with the Registry CLI
|
||||||
```
|
```
|
||||||
$ laconic-so --stack fixturenet-laconic-loaded deploy exec cli "laconic cns status"
|
$ laconic-so --stack fixturenet-laconic-loaded deploy exec cli "laconic registry status"
|
||||||
```
|
```
|
||||||
## 7. View the laconic console
|
## 7. View the laconic console
|
||||||
Get the URL for the console web app with this command (the port number will be different for each deployment):
|
Get the URL for the console web app with this command (the port number will be different for each deployment):
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ repos:
|
|||||||
- github.com/lirewine/crypto
|
- github.com/lirewine/crypto
|
||||||
- github.com/lirewine/gem
|
- github.com/lirewine/gem
|
||||||
- github.com/lirewine/sdk
|
- github.com/lirewine/sdk
|
||||||
- git.vdb.to/cerc-io/laconic-sdk
|
- git.vdb.to/cerc-io/registry-sdk
|
||||||
- git.vdb.to/cerc-io/laconic-registry-cli
|
- git.vdb.to/cerc-io/laconic-registry-cli
|
||||||
- git.vdb.to/cerc-io/laconic-console
|
- git.vdb.to/cerc-io/laconic-console
|
||||||
npms:
|
npms:
|
||||||
- laconic-sdk
|
- registry-sdk
|
||||||
- laconic-registry-cli
|
- laconic-registry-cli
|
||||||
- debug
|
- debug
|
||||||
- crypto
|
- crypto
|
||||||
|
|||||||
@@ -44,5 +44,5 @@ $ laconic-so --stack fixturenet-laconicd deploy logs
|
|||||||
```
|
```
|
||||||
## 6. Test with the Registry CLI
|
## 6. Test with the Registry CLI
|
||||||
```
|
```
|
||||||
$ laconic-so --stack fixturenet-laconicd deploy exec cli "laconic cns status"
|
$ laconic-so --stack fixturenet-laconicd deploy exec cli "laconic registry status"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ name: fixturenet-laconicd
|
|||||||
description: "A laconicd fixturenet"
|
description: "A laconicd fixturenet"
|
||||||
repos:
|
repos:
|
||||||
- git.vdb.to/cerc-io/laconicd
|
- git.vdb.to/cerc-io/laconicd
|
||||||
- git.vdb.to/cerc-io/laconic-sdk
|
- git.vdb.to/cerc-io/registry-sdk
|
||||||
- git.vdb.to/cerc-io/laconic-registry-cli
|
- git.vdb.to/cerc-io/laconic-registry-cli
|
||||||
npms:
|
npms:
|
||||||
- laconic-sdk
|
- registry-sdk
|
||||||
- laconic-registry-cli
|
- laconic-registry-cli
|
||||||
containers:
|
containers:
|
||||||
- cerc/laconicd
|
- cerc/laconicd
|
||||||
|
|||||||
@@ -115,13 +115,38 @@ def _insert_persistent_peers(config_dir: Path, new_persistent_peers: str):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
with open(config_file_path, "r") as input_file:
|
with open(config_file_path, "r") as input_file:
|
||||||
config_file_content = input_file.read()
|
config_file_content = input_file.read()
|
||||||
persistent_peers_pattern = '^persistent_peers = ""'
|
persistent_peers_pattern = r'^persistent_peers = ""'
|
||||||
replace_with = f"persistent_peers = \"{new_persistent_peers}\""
|
replace_with = f"persistent_peers = \"{new_persistent_peers}\""
|
||||||
config_file_content = re.sub(persistent_peers_pattern, replace_with, config_file_content, flags=re.MULTILINE)
|
config_file_content = re.sub(persistent_peers_pattern, replace_with, config_file_content, flags=re.MULTILINE)
|
||||||
with open(config_file_path, "w") as output_file:
|
with open(config_file_path, "w") as output_file:
|
||||||
output_file.write(config_file_content)
|
output_file.write(config_file_content)
|
||||||
|
|
||||||
|
|
||||||
|
def _enable_cors(config_dir: Path):
|
||||||
|
config_file_path = config_dir.joinpath("config.toml")
|
||||||
|
if not config_file_path.exists():
|
||||||
|
print("Error: config.toml not found")
|
||||||
|
sys.exit(1)
|
||||||
|
with open(config_file_path, "r") as input_file:
|
||||||
|
config_file_content = input_file.read()
|
||||||
|
cors_pattern = r'^cors_allowed_origins = \[]'
|
||||||
|
replace_with = 'cors_allowed_origins = ["*"]'
|
||||||
|
config_file_content = re.sub(cors_pattern, replace_with, config_file_content, flags=re.MULTILINE)
|
||||||
|
with open(config_file_path, "w") as output_file:
|
||||||
|
output_file.write(config_file_content)
|
||||||
|
app_file_path = config_dir.joinpath("app.toml")
|
||||||
|
if not app_file_path.exists():
|
||||||
|
print("Error: app.toml not found")
|
||||||
|
sys.exit(1)
|
||||||
|
with open(app_file_path, "r") as input_file:
|
||||||
|
app_file_content = input_file.read()
|
||||||
|
cors_pattern = r'^enabled-unsafe-cors = false'
|
||||||
|
replace_with = "enabled-unsafe-cors = true"
|
||||||
|
app_file_content = re.sub(cors_pattern, replace_with, app_file_content, flags=re.MULTILINE)
|
||||||
|
with open(app_file_path, "w") as output_file:
|
||||||
|
output_file.write(app_file_content)
|
||||||
|
|
||||||
|
|
||||||
def _phase_from_params(parameters):
|
def _phase_from_params(parameters):
|
||||||
phase = SetupPhase.ILLEGAL
|
phase = SetupPhase.ILLEGAL
|
||||||
if parameters.initialize_network:
|
if parameters.initialize_network:
|
||||||
@@ -292,6 +317,8 @@ def create(deployment_context: DeploymentContext, extra_args):
|
|||||||
if extra_args[1]:
|
if extra_args[1]:
|
||||||
initial_persistent_peers = extra_args[1]
|
initial_persistent_peers = extra_args[1]
|
||||||
_insert_persistent_peers(deployment_config_dir, initial_persistent_peers)
|
_insert_persistent_peers(deployment_config_dir, initial_persistent_peers)
|
||||||
|
# Enable CORS headers so explorers and so on can talk to the node
|
||||||
|
_enable_cors(deployment_config_dir)
|
||||||
# Copy the data directory contents into our deployment
|
# Copy the data directory contents into our deployment
|
||||||
# TODO: change this to work with non local paths
|
# TODO: change this to work with non local paths
|
||||||
deployment_data_dir = deployment_context.deployment_dir.joinpath("data", "laconicd-data")
|
deployment_data_dir = deployment_context.deployment_dir.joinpath("data", "laconicd-data")
|
||||||
|
|||||||
@@ -2,16 +2,17 @@ version: "1.0"
|
|||||||
name: mainnet-laconic
|
name: mainnet-laconic
|
||||||
description: "Mainnet laconic node"
|
description: "Mainnet laconic node"
|
||||||
repos:
|
repos:
|
||||||
- cerc-io/laconicd
|
- git.vdb.to/cerc-io/laconicd
|
||||||
- lirewine/debug
|
- github.com/lirewine/debug
|
||||||
- lirewine/crypto
|
- github.com/lirewine/crypto
|
||||||
- lirewine/gem
|
- github.com/lirewine/gem
|
||||||
- lirewine/sdk
|
- github.com/lirewine/sdk
|
||||||
- cerc-io/laconic-sdk
|
- git.vdb.to/cerc-io/registry-sdk
|
||||||
- cerc-io/laconic-registry-cli
|
- git.vdb.to/cerc-io/laconic-registry-cli
|
||||||
- cerc-io/laconic-console
|
- git.vdb.to/cerc-io/laconic-console
|
||||||
|
- github.com/ping-pub/explorer
|
||||||
npms:
|
npms:
|
||||||
- laconic-sdk
|
- registry-sdk
|
||||||
- laconic-registry-cli
|
- laconic-registry-cli
|
||||||
- debug
|
- debug
|
||||||
- crypto
|
- crypto
|
||||||
@@ -23,7 +24,8 @@ containers:
|
|||||||
- cerc/laconic-registry-cli
|
- cerc/laconic-registry-cli
|
||||||
- cerc/webapp-base
|
- cerc/webapp-base
|
||||||
- cerc/laconic-console-host
|
- cerc/laconic-console-host
|
||||||
|
- cerc/ping-pub
|
||||||
pods:
|
pods:
|
||||||
- mainnet-laconicd
|
- mainnet-laconicd
|
||||||
- fixturenet-laconic-console
|
- fixturenet-laconic-console
|
||||||
|
- laconic-explorer
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ Setup a test chain:
|
|||||||
```bash
|
```bash
|
||||||
export CERC_NPM_REGISTRY_URL=https://git.vdb.to/api/packages/cerc-io/npm/
|
export CERC_NPM_REGISTRY_URL=https://git.vdb.to/api/packages/cerc-io/npm/
|
||||||
|
|
||||||
laconic-so --stack fixturenet-laconic-loaded setup-repositories --include git.vdb.to/cerc-io/laconicd,git.vdb.to/cerc-io/laconic-sdk,git.vdb.to/cerc-io/laconic-registry-cli,git.vdb.to/cerc-io/laconic-console
|
laconic-so --stack fixturenet-laconic-loaded setup-repositories --include git.vdb.to/cerc-io/laconicd,git.vdb.to/cerc-io/registry-sdk,git.vdb.to/cerc-io/laconic-registry-cli,git.vdb.to/cerc-io/laconic-console
|
||||||
|
|
||||||
laconic-so --stack fixturenet-laconic-loaded build-containers
|
laconic-so --stack fixturenet-laconic-loaded build-containers
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,15 @@ import click
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from stack_orchestrator import constants
|
from stack_orchestrator import constants
|
||||||
from stack_orchestrator.opts import opts
|
from stack_orchestrator.opts import opts
|
||||||
from stack_orchestrator.util import include_exclude_check, get_parsed_stack_config, global_options2, get_dev_root_path
|
from stack_orchestrator.util import (
|
||||||
from stack_orchestrator.util import resolve_compose_file
|
get_stack_path,
|
||||||
|
include_exclude_check,
|
||||||
|
get_parsed_stack_config,
|
||||||
|
global_options2,
|
||||||
|
get_dev_root_path,
|
||||||
|
stack_is_in_deployment,
|
||||||
|
resolve_compose_file,
|
||||||
|
)
|
||||||
from stack_orchestrator.deploy.deployer import Deployer, DeployerException
|
from stack_orchestrator.deploy.deployer import Deployer, DeployerException
|
||||||
from stack_orchestrator.deploy.deployer_factory import getDeployer
|
from stack_orchestrator.deploy.deployer_factory import getDeployer
|
||||||
from stack_orchestrator.deploy.deploy_types import ClusterContext, DeployCommandContext
|
from stack_orchestrator.deploy.deploy_types import ClusterContext, DeployCommandContext
|
||||||
@@ -60,6 +67,7 @@ def command(ctx, include, exclude, env_file, cluster, deploy_to):
|
|||||||
if deploy_to is None:
|
if deploy_to is None:
|
||||||
deploy_to = "compose"
|
deploy_to = "compose"
|
||||||
|
|
||||||
|
stack = get_stack_path(stack)
|
||||||
ctx.obj = create_deploy_context(global_options2(ctx), None, stack, include, exclude, cluster, env_file, deploy_to)
|
ctx.obj = create_deploy_context(global_options2(ctx), None, stack, include, exclude, cluster, env_file, deploy_to)
|
||||||
# Subcommand is executed now, by the magic of click
|
# Subcommand is executed now, by the magic of click
|
||||||
|
|
||||||
@@ -274,16 +282,12 @@ def _make_default_cluster_name(deployment, compose_dir, stack, include, exclude)
|
|||||||
|
|
||||||
# stack has to be either PathLike pointing to a stack yml file, or a string with the name of a known stack
|
# stack has to be either PathLike pointing to a stack yml file, or a string with the name of a known stack
|
||||||
def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
|
def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
|
||||||
|
|
||||||
dev_root_path = get_dev_root_path(ctx)
|
dev_root_path = get_dev_root_path(ctx)
|
||||||
|
|
||||||
# TODO: huge hack, fix this
|
# TODO: hack, this should be encapsulated by the deployment context.
|
||||||
# If the caller passed a path for the stack file, then we know that we can get the compose files
|
deployment = stack_is_in_deployment(stack)
|
||||||
# from the same directory
|
if deployment:
|
||||||
deployment = False
|
compose_dir = stack.joinpath("compose")
|
||||||
if isinstance(stack, os.PathLike):
|
|
||||||
compose_dir = stack.parent.joinpath("compose")
|
|
||||||
deployment = True
|
|
||||||
else:
|
else:
|
||||||
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
||||||
compose_dir = Path(__file__).absolute().parent.parent.joinpath("data", "compose")
|
compose_dir = Path(__file__).absolute().parent.parent.joinpath("data", "compose")
|
||||||
|
|||||||
@@ -50,15 +50,15 @@ def command(ctx, dir):
|
|||||||
|
|
||||||
def make_deploy_context(ctx) -> DeployCommandContext:
|
def make_deploy_context(ctx) -> DeployCommandContext:
|
||||||
context: DeploymentContext = ctx.obj
|
context: DeploymentContext = ctx.obj
|
||||||
stack_file_path = context.get_stack_file()
|
|
||||||
env_file = context.get_env_file()
|
env_file = context.get_env_file()
|
||||||
cluster_name = context.get_cluster_id()
|
cluster_name = context.get_cluster_id()
|
||||||
if constants.deploy_to_key in context.spec.obj:
|
if constants.deploy_to_key in context.spec.obj:
|
||||||
deployment_type = context.spec.obj[constants.deploy_to_key]
|
deployment_type = context.spec.obj[constants.deploy_to_key]
|
||||||
else:
|
else:
|
||||||
deployment_type = constants.compose_deploy_type
|
deployment_type = constants.compose_deploy_type
|
||||||
return create_deploy_context(ctx.parent.parent.obj, context, stack_file_path, None, None, cluster_name, env_file,
|
stack = context.deployment_dir
|
||||||
deployment_type)
|
return create_deploy_context(ctx.parent.parent.obj, context, stack, None, None,
|
||||||
|
cluster_name, env_file, deployment_type)
|
||||||
|
|
||||||
|
|
||||||
@command.command()
|
@command.command()
|
||||||
@@ -123,6 +123,7 @@ def push_images(ctx):
|
|||||||
@click.argument('extra_args', nargs=-1) # help: command: port <service1> <service2>
|
@click.argument('extra_args', nargs=-1) # help: command: port <service1> <service2>
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def port(ctx, extra_args):
|
def port(ctx, extra_args):
|
||||||
|
ctx.obj = make_deploy_context(ctx)
|
||||||
port_operation(ctx, extra_args)
|
port_operation(ctx, extra_args)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ from secrets import token_hex
|
|||||||
import sys
|
import sys
|
||||||
from stack_orchestrator import constants
|
from stack_orchestrator import constants
|
||||||
from stack_orchestrator.opts import opts
|
from stack_orchestrator.opts import opts
|
||||||
from stack_orchestrator.util import (get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config,
|
from stack_orchestrator.util import (get_stack_path, get_parsed_deployment_spec, get_parsed_stack_config,
|
||||||
global_options, get_yaml, get_pod_list, get_pod_file_path, pod_has_scripts,
|
global_options, get_yaml, get_pod_list, get_pod_file_path, pod_has_scripts,
|
||||||
get_pod_script_paths, get_plugin_code_paths, error_exit, env_var_map_from_file,
|
get_pod_script_paths, get_plugin_code_paths, error_exit, env_var_map_from_file,
|
||||||
resolve_config_dir)
|
resolve_config_dir)
|
||||||
@@ -238,6 +238,11 @@ def _find_extra_config_dirs(parsed_pod_file, pod):
|
|||||||
config_dir = host_path.split("/")[2]
|
config_dir = host_path.split("/")[2]
|
||||||
if config_dir != pod:
|
if config_dir != pod:
|
||||||
config_dirs.add(config_dir)
|
config_dirs.add(config_dir)
|
||||||
|
for env_file in service_info.get("env_file", []):
|
||||||
|
if env_file.startswith("../config"):
|
||||||
|
config_dir = env_file.split("/")[2]
|
||||||
|
if config_dir != pod:
|
||||||
|
config_dirs.add(config_dir)
|
||||||
return config_dirs
|
return config_dirs
|
||||||
|
|
||||||
|
|
||||||
@@ -454,7 +459,7 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw
|
|||||||
_check_volume_definitions(parsed_spec)
|
_check_volume_definitions(parsed_spec)
|
||||||
stack_name = parsed_spec["stack"]
|
stack_name = parsed_spec["stack"]
|
||||||
deployment_type = parsed_spec[constants.deploy_to_key]
|
deployment_type = parsed_spec[constants.deploy_to_key]
|
||||||
stack_file = get_stack_file_path(stack_name)
|
stack_file = get_stack_path(stack_name).joinpath(constants.stack_file_name)
|
||||||
parsed_stack = get_parsed_stack_config(stack_name)
|
parsed_stack = get_parsed_stack_config(stack_name)
|
||||||
if opts.o.debug:
|
if opts.o.debug:
|
||||||
print(f"parsed spec: {parsed_spec}")
|
print(f"parsed spec: {parsed_spec}")
|
||||||
@@ -467,7 +472,7 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw
|
|||||||
os.mkdir(deployment_dir_path)
|
os.mkdir(deployment_dir_path)
|
||||||
# Copy spec file and the stack file into the deployment dir
|
# Copy spec file and the stack file into the deployment dir
|
||||||
copyfile(spec_file, deployment_dir_path.joinpath(constants.spec_file_name))
|
copyfile(spec_file, deployment_dir_path.joinpath(constants.spec_file_name))
|
||||||
copyfile(stack_file, deployment_dir_path.joinpath(os.path.basename(stack_file)))
|
copyfile(stack_file, deployment_dir_path.joinpath(constants.stack_file_name))
|
||||||
_create_deployment_file(deployment_dir_path)
|
_create_deployment_file(deployment_dir_path)
|
||||||
# Copy any config varibles from the spec file into an env file suitable for compose
|
# Copy any config varibles from the spec file into an env file suitable for compose
|
||||||
_write_config_file(spec_file, deployment_dir_path.joinpath(constants.config_file_name))
|
_write_config_file(spec_file, deployment_dir_path.joinpath(constants.config_file_name))
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import uuid
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from stack_orchestrator.deploy.images import remote_image_exists, add_tags_to_image
|
from stack_orchestrator.deploy.images import remote_image_exists
|
||||||
from stack_orchestrator.deploy.webapp import deploy_webapp
|
from stack_orchestrator.deploy.webapp import deploy_webapp
|
||||||
from stack_orchestrator.deploy.webapp.util import (LaconicRegistryClient, TimedLogger,
|
from stack_orchestrator.deploy.webapp.util import (LaconicRegistryClient, TimedLogger,
|
||||||
build_container_image, push_container_image,
|
build_container_image, push_container_image,
|
||||||
@@ -66,8 +66,8 @@ def process_app_deployment_request(
|
|||||||
fqdn = f"{requested_name}.{default_dns_suffix}"
|
fqdn = f"{requested_name}.{default_dns_suffix}"
|
||||||
|
|
||||||
# 3. check ownership of existing dnsrecord vs this request
|
# 3. check ownership of existing dnsrecord vs this request
|
||||||
dns_crn = f"{dns_record_namespace}/{fqdn}"
|
dns_lrn = f"{dns_record_namespace}/{fqdn}"
|
||||||
dns_record = laconic.get_record(dns_crn)
|
dns_record = laconic.get_record(dns_lrn)
|
||||||
if dns_record:
|
if dns_record:
|
||||||
matched_owner = match_owner(app_deployment_request, dns_record)
|
matched_owner = match_owner(app_deployment_request, dns_record)
|
||||||
if not matched_owner and dns_record.attributes.request:
|
if not matched_owner and dns_record.attributes.request:
|
||||||
@@ -77,9 +77,9 @@ def process_app_deployment_request(
|
|||||||
logger.log(f"Matched DnsRecord ownership: {matched_owner}")
|
logger.log(f"Matched DnsRecord ownership: {matched_owner}")
|
||||||
else:
|
else:
|
||||||
raise Exception("Unable to confirm ownership of DnsRecord %s for request %s" %
|
raise Exception("Unable to confirm ownership of DnsRecord %s for request %s" %
|
||||||
(dns_crn, app_deployment_request.id))
|
(dns_lrn, app_deployment_request.id))
|
||||||
elif "preexisting" == fqdn_policy:
|
elif "preexisting" == fqdn_policy:
|
||||||
raise Exception(f"No pre-existing DnsRecord {dns_crn} could be found for request {app_deployment_request.id}.")
|
raise Exception(f"No pre-existing DnsRecord {dns_lrn} could be found for request {app_deployment_request.id}.")
|
||||||
|
|
||||||
# 4. get build and runtime config from request
|
# 4. get build and runtime config from request
|
||||||
env_filename = None
|
env_filename = None
|
||||||
@@ -90,43 +90,54 @@ def process_app_deployment_request(
|
|||||||
file.write("%s=%s\n" % (k, shlex.quote(str(v))))
|
file.write("%s=%s\n" % (k, shlex.quote(str(v))))
|
||||||
|
|
||||||
# 5. determine new or existing deployment
|
# 5. determine new or existing deployment
|
||||||
# a. check for deployment crn
|
# a. check for deployment lrn
|
||||||
app_deployment_crn = f"{deployment_record_namespace}/{fqdn}"
|
app_deployment_lrn = f"{deployment_record_namespace}/{fqdn}"
|
||||||
if app_deployment_request.attributes.deployment:
|
if app_deployment_request.attributes.deployment:
|
||||||
app_deployment_crn = app_deployment_request.attributes.deployment
|
app_deployment_lrn = app_deployment_request.attributes.deployment
|
||||||
if not app_deployment_crn.startswith(deployment_record_namespace):
|
if not app_deployment_lrn.startswith(deployment_record_namespace):
|
||||||
raise Exception("Deployment CRN %s is not in a supported namespace" % app_deployment_request.attributes.deployment)
|
raise Exception("Deployment CRN %s is not in a supported namespace" % app_deployment_request.attributes.deployment)
|
||||||
|
|
||||||
deployment_record = laconic.get_record(app_deployment_crn)
|
deployment_record = laconic.get_record(app_deployment_lrn)
|
||||||
deployment_dir = os.path.join(deployment_parent_dir, fqdn)
|
deployment_dir = os.path.join(deployment_parent_dir, fqdn)
|
||||||
|
# At present we use this to generate a unique but stable ID for the app's host container
|
||||||
|
# TODO: implement support to derive this transparently from the already-unique deployment id
|
||||||
|
unique_deployment_id = hashlib.md5(fqdn.encode()).hexdigest()[:16]
|
||||||
deployment_config_file = os.path.join(deployment_dir, "config.env")
|
deployment_config_file = os.path.join(deployment_dir, "config.env")
|
||||||
# TODO: Is there any reason not to simplify the hash input to the app_deployment_crn?
|
deployment_container_tag = "laconic-webapp/%s:local" % unique_deployment_id
|
||||||
deployment_container_tag = "laconic-webapp/%s:local" % hashlib.md5(deployment_dir.encode()).hexdigest()
|
|
||||||
app_image_shared_tag = f"laconic-webapp/{app.id}:local"
|
app_image_shared_tag = f"laconic-webapp/{app.id}:local"
|
||||||
# b. check for deployment directory (create if necessary)
|
# b. check for deployment directory (create if necessary)
|
||||||
if not os.path.exists(deployment_dir):
|
if not os.path.exists(deployment_dir):
|
||||||
if deployment_record:
|
if deployment_record:
|
||||||
raise Exception("Deployment record %s exists, but not deployment dir %s. Please remove name." %
|
raise Exception("Deployment record %s exists, but not deployment dir %s. Please remove name." %
|
||||||
(app_deployment_crn, deployment_dir))
|
(app_deployment_lrn, deployment_dir))
|
||||||
print("deploy_webapp", deployment_dir)
|
logger.log(f"Creating webapp deployment in: {deployment_dir} with container id: {deployment_container_tag}")
|
||||||
deploy_webapp.create_deployment(ctx, deployment_dir, deployment_container_tag,
|
deploy_webapp.create_deployment(ctx, deployment_dir, deployment_container_tag,
|
||||||
f"https://{fqdn}", kube_config, image_registry, env_filename)
|
f"https://{fqdn}", kube_config, image_registry, env_filename)
|
||||||
elif env_filename:
|
elif env_filename:
|
||||||
shutil.copyfile(env_filename, deployment_config_file)
|
shutil.copyfile(env_filename, deployment_config_file)
|
||||||
|
|
||||||
needs_k8s_deploy = False
|
needs_k8s_deploy = False
|
||||||
|
if force_rebuild:
|
||||||
|
logger.log("--force-rebuild is enabled so the container will always be built now, even if nothing has changed in the app")
|
||||||
# 6. build container (if needed)
|
# 6. build container (if needed)
|
||||||
if not deployment_record or deployment_record.attributes.application != app.id:
|
# TODO: add a comment that explains what this code is doing (not clear to me)
|
||||||
|
if not deployment_record or deployment_record.attributes.application != app.id or force_rebuild:
|
||||||
needs_k8s_deploy = True
|
needs_k8s_deploy = True
|
||||||
# check if the image already exists
|
# check if the image already exists
|
||||||
shared_tag_exists = remote_image_exists(image_registry, app_image_shared_tag)
|
shared_tag_exists = remote_image_exists(image_registry, app_image_shared_tag)
|
||||||
|
# Note: in the code below, calls to add_tags_to_image() won't work at present.
|
||||||
|
# This is because SO deployment code in general re-names the container image
|
||||||
|
# to be unique to the deployment. This is done transparently
|
||||||
|
# and so when we call add_tags_to_image() here and try to add tags to the remote image,
|
||||||
|
# we get the image name wrong. Accordingly I've disabled the relevant code for now.
|
||||||
|
# This is safe because we are running with --force-rebuild at present
|
||||||
if shared_tag_exists and not force_rebuild:
|
if shared_tag_exists and not force_rebuild:
|
||||||
# simply add our unique tag to the existing image and we are done
|
# simply add our unique tag to the existing image and we are done
|
||||||
logger.log(
|
logger.log(
|
||||||
f"Existing image found for this app: {app_image_shared_tag} "
|
f"(SKIPPED) Existing image found for this app: {app_image_shared_tag} "
|
||||||
"tagging it with: {deployment_container_tag} to use in this deployment"
|
"tagging it with: {deployment_container_tag} to use in this deployment"
|
||||||
)
|
)
|
||||||
add_tags_to_image(image_registry, app_image_shared_tag, deployment_container_tag)
|
# add_tags_to_image(image_registry, app_image_shared_tag, deployment_container_tag)
|
||||||
logger.log("Tag complete")
|
logger.log("Tag complete")
|
||||||
else:
|
else:
|
||||||
extra_build_args = [] # TODO: pull from request
|
extra_build_args = [] # TODO: pull from request
|
||||||
@@ -137,8 +148,10 @@ def process_app_deployment_request(
|
|||||||
push_container_image(deployment_dir, logger)
|
push_container_image(deployment_dir, logger)
|
||||||
logger.log("Push complete")
|
logger.log("Push complete")
|
||||||
# The build/push commands above will use the unique deployment tag, so now we need to add the shared tag.
|
# The build/push commands above will use the unique deployment tag, so now we need to add the shared tag.
|
||||||
logger.log(f"Adding global app image tag: {app_image_shared_tag} to newly built image: {deployment_container_tag}")
|
logger.log(
|
||||||
add_tags_to_image(image_registry, deployment_container_tag, app_image_shared_tag)
|
f"(SKIPPED) Adding global app image tag: {app_image_shared_tag} to newly built image: {deployment_container_tag}"
|
||||||
|
)
|
||||||
|
# add_tags_to_image(image_registry, deployment_container_tag, app_image_shared_tag)
|
||||||
logger.log("Tag complete")
|
logger.log("Tag complete")
|
||||||
else:
|
else:
|
||||||
logger.log("Requested app is already deployed, skipping build and image push")
|
logger.log("Requested app is already deployed, skipping build and image push")
|
||||||
@@ -160,9 +173,9 @@ def process_app_deployment_request(
|
|||||||
laconic,
|
laconic,
|
||||||
app,
|
app,
|
||||||
deployment_record,
|
deployment_record,
|
||||||
app_deployment_crn,
|
app_deployment_lrn,
|
||||||
dns_record,
|
dns_record,
|
||||||
dns_crn,
|
dns_lrn,
|
||||||
deployment_dir,
|
deployment_dir,
|
||||||
app_deployment_request,
|
app_deployment_request,
|
||||||
logger
|
logger
|
||||||
@@ -201,8 +214,8 @@ def dump_known_requests(filename, requests, status="SEEN"):
|
|||||||
@click.option("--only-update-state", help="Only update the state file, don't process any requests anything.", is_flag=True)
|
@click.option("--only-update-state", help="Only update the state file, don't process any requests anything.", is_flag=True)
|
||||||
@click.option("--dns-suffix", help="DNS domain to use eg, laconic.servesthe.world")
|
@click.option("--dns-suffix", help="DNS domain to use eg, laconic.servesthe.world")
|
||||||
@click.option("--fqdn-policy", help="How to handle requests with an FQDN: prohibit, allow, preexisting", default="prohibit")
|
@click.option("--fqdn-policy", help="How to handle requests with an FQDN: prohibit, allow, preexisting", default="prohibit")
|
||||||
@click.option("--record-namespace-dns", help="eg, crn://laconic/dns")
|
@click.option("--record-namespace-dns", help="eg, lrn://laconic/dns")
|
||||||
@click.option("--record-namespace-deployments", help="eg, crn://laconic/deployments")
|
@click.option("--record-namespace-deployments", help="eg, lrn://laconic/deployments")
|
||||||
@click.option("--dry-run", help="Don't do anything, just report what would be done.", is_flag=True)
|
@click.option("--dry-run", help="Don't do anything, just report what would be done.", is_flag=True)
|
||||||
@click.option("--include-tags", help="Only include requests with matching tags (comma-separated).", default="")
|
@click.option("--include-tags", help="Only include requests with matching tags (comma-separated).", default="")
|
||||||
@click.option("--exclude-tags", help="Exclude requests with matching tags (comma-separated).", default="")
|
@click.option("--exclude-tags", help="Exclude requests with matching tags (comma-separated).", default="")
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class LaconicRegistryClient:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def list_records(self, criteria={}, all=False):
|
def list_records(self, criteria={}, all=False):
|
||||||
args = ["laconic", "-c", self.config_file, "cns", "record", "list"]
|
args = ["laconic", "-c", self.config_file, "registry", "record", "list"]
|
||||||
|
|
||||||
if all:
|
if all:
|
||||||
args.append("--all")
|
args.append("--all")
|
||||||
@@ -112,13 +112,13 @@ class LaconicRegistryClient:
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def is_crn(self, name_or_id: str):
|
def is_lrn(self, name_or_id: str):
|
||||||
if name_or_id:
|
if name_or_id:
|
||||||
return str(name_or_id).startswith("crn://")
|
return str(name_or_id).startswith("lrn://")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def is_id(self, name_or_id: str):
|
def is_id(self, name_or_id: str):
|
||||||
return not self.is_crn(name_or_id)
|
return not self.is_lrn(name_or_id)
|
||||||
|
|
||||||
def _add_to_cache(self, records):
|
def _add_to_cache(self, records):
|
||||||
if not records:
|
if not records:
|
||||||
@@ -127,8 +127,8 @@ class LaconicRegistryClient:
|
|||||||
for p in records:
|
for p in records:
|
||||||
self.cache["name_or_id"][p.id] = p
|
self.cache["name_or_id"][p.id] = p
|
||||||
if p.names:
|
if p.names:
|
||||||
for crn in p.names:
|
for lrn in p.names:
|
||||||
self.cache["name_or_id"][crn] = p
|
self.cache["name_or_id"][lrn] = p
|
||||||
if p.attributes.type not in self.cache:
|
if p.attributes.type not in self.cache:
|
||||||
self.cache[p.attributes.type] = []
|
self.cache[p.attributes.type] = []
|
||||||
self.cache[p.attributes.type].append(p)
|
self.cache[p.attributes.type].append(p)
|
||||||
@@ -140,7 +140,7 @@ class LaconicRegistryClient:
|
|||||||
if name in self.cache.name_or_id:
|
if name in self.cache.name_or_id:
|
||||||
return self.cache.name_or_id[name]
|
return self.cache.name_or_id[name]
|
||||||
|
|
||||||
args = ["laconic", "-c", self.config_file, "cns", "name", "resolve", name]
|
args = ["laconic", "-c", self.config_file, "registry", "name", "resolve", name]
|
||||||
|
|
||||||
parsed = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args))]
|
parsed = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args))]
|
||||||
if parsed:
|
if parsed:
|
||||||
@@ -158,14 +158,14 @@ class LaconicRegistryClient:
|
|||||||
if name_or_id in self.cache.name_or_id:
|
if name_or_id in self.cache.name_or_id:
|
||||||
return self.cache.name_or_id[name_or_id]
|
return self.cache.name_or_id[name_or_id]
|
||||||
|
|
||||||
if self.is_crn(name_or_id):
|
if self.is_lrn(name_or_id):
|
||||||
return self.resolve(name_or_id)
|
return self.resolve(name_or_id)
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"laconic",
|
"laconic",
|
||||||
"-c",
|
"-c",
|
||||||
self.config_file,
|
self.config_file,
|
||||||
"cns",
|
"registry",
|
||||||
"record",
|
"record",
|
||||||
"get",
|
"get",
|
||||||
"--id",
|
"--id",
|
||||||
@@ -203,7 +203,16 @@ class LaconicRegistryClient:
|
|||||||
print(open(record_fname, 'r').read(), file=self.log_file)
|
print(open(record_fname, 'r').read(), file=self.log_file)
|
||||||
|
|
||||||
new_record_id = json.loads(
|
new_record_id = json.loads(
|
||||||
logged_cmd(self.log_file, "laconic", "-c", self.config_file, "cns", "record", "publish", "--filename", record_fname)
|
logged_cmd(
|
||||||
|
self.log_file,
|
||||||
|
"laconic", "-c",
|
||||||
|
self.config_file,
|
||||||
|
"registry",
|
||||||
|
"record",
|
||||||
|
"publish",
|
||||||
|
"--filename",
|
||||||
|
record_fname
|
||||||
|
)
|
||||||
)["id"]
|
)["id"]
|
||||||
for name in names:
|
for name in names:
|
||||||
self.set_name(name, new_record_id)
|
self.set_name(name, new_record_id)
|
||||||
@@ -212,10 +221,10 @@ class LaconicRegistryClient:
|
|||||||
logged_cmd(self.log_file, "rm", "-rf", tmpdir)
|
logged_cmd(self.log_file, "rm", "-rf", tmpdir)
|
||||||
|
|
||||||
def set_name(self, name, record_id):
|
def set_name(self, name, record_id):
|
||||||
logged_cmd(self.log_file, "laconic", "-c", self.config_file, "cns", "name", "set", name, record_id)
|
logged_cmd(self.log_file, "laconic", "-c", self.config_file, "registry", "name", "set", name, record_id)
|
||||||
|
|
||||||
def delete_name(self, name):
|
def delete_name(self, name):
|
||||||
logged_cmd(self.log_file, "laconic", "-c", self.config_file, "cns", "name", "delete", name)
|
logged_cmd(self.log_file, "laconic", "-c", self.config_file, "registry", "name", "delete", name)
|
||||||
|
|
||||||
|
|
||||||
def file_hash(filename):
|
def file_hash(filename):
|
||||||
@@ -242,6 +251,7 @@ def determine_base_container(clone_dir, app_type="webapp"):
|
|||||||
def build_container_image(app_record, tag, extra_build_args=[], logger=None):
|
def build_container_image(app_record, tag, extra_build_args=[], logger=None):
|
||||||
tmpdir = tempfile.mkdtemp()
|
tmpdir = tempfile.mkdtemp()
|
||||||
|
|
||||||
|
# TODO: determine if this code could be calling into the Python git library like setup-repositories
|
||||||
try:
|
try:
|
||||||
record_id = app_record["id"]
|
record_id = app_record["id"]
|
||||||
ref = app_record.attributes.repository_ref
|
ref = app_record.attributes.repository_ref
|
||||||
@@ -249,6 +259,16 @@ def build_container_image(app_record, tag, extra_build_args=[], logger=None):
|
|||||||
clone_dir = os.path.join(tmpdir, record_id)
|
clone_dir = os.path.join(tmpdir, record_id)
|
||||||
|
|
||||||
logger.log(f"Cloning repository {repo} to {clone_dir} ...")
|
logger.log(f"Cloning repository {repo} to {clone_dir} ...")
|
||||||
|
# Set github credentials if present running a command like:
|
||||||
|
# git config --global url."https://${TOKEN}:@github.com/".insteadOf "https://github.com/"
|
||||||
|
github_token = os.environ.get("DEPLOYER_GITHUB_TOKEN")
|
||||||
|
if github_token:
|
||||||
|
logger.log("Github token detected, setting it in the git environment")
|
||||||
|
git_config_args = [
|
||||||
|
"git", "config", "--global", f"url.https://{github_token}:@github.com/.insteadOf", "https://github.com/"
|
||||||
|
]
|
||||||
|
result = subprocess.run(git_config_args, stdout=logger.file, stderr=logger.file)
|
||||||
|
result.check_returncode()
|
||||||
if ref:
|
if ref:
|
||||||
# TODO: Determing branch or hash, and use depth 1 if we can.
|
# TODO: Determing branch or hash, and use depth 1 if we can.
|
||||||
git_env = dict(os.environ.copy())
|
git_env = dict(os.environ.copy())
|
||||||
@@ -265,6 +285,7 @@ def build_container_image(app_record, tag, extra_build_args=[], logger=None):
|
|||||||
logger.log(f"git checkout failed. Does ref {ref} exist?")
|
logger.log(f"git checkout failed. Does ref {ref} exist?")
|
||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
|
# TODO: why is this code different vs the branch above (run vs check_call, and no prompt disable)?
|
||||||
result = subprocess.run(["git", "clone", "--depth", "1", repo, clone_dir], stdout=logger.file, stderr=logger.file)
|
result = subprocess.run(["git", "clone", "--depth", "1", repo, clone_dir], stdout=logger.file, stderr=logger.file)
|
||||||
result.check_returncode()
|
result.check_returncode()
|
||||||
|
|
||||||
@@ -314,9 +335,9 @@ def deploy_to_k8s(deploy_record, deployment_dir, logger):
|
|||||||
def publish_deployment(laconic: LaconicRegistryClient,
|
def publish_deployment(laconic: LaconicRegistryClient,
|
||||||
app_record,
|
app_record,
|
||||||
deploy_record,
|
deploy_record,
|
||||||
deployment_crn,
|
deployment_lrn,
|
||||||
dns_record,
|
dns_record,
|
||||||
dns_crn,
|
dns_lrn,
|
||||||
deployment_dir,
|
deployment_dir,
|
||||||
app_deployment_request=None,
|
app_deployment_request=None,
|
||||||
logger=None):
|
logger=None):
|
||||||
@@ -351,7 +372,7 @@ def publish_deployment(laconic: LaconicRegistryClient,
|
|||||||
|
|
||||||
if logger:
|
if logger:
|
||||||
logger.log("Publishing DnsRecord.")
|
logger.log("Publishing DnsRecord.")
|
||||||
dns_id = laconic.publish(new_dns_record, [dns_crn])
|
dns_id = laconic.publish(new_dns_record, [dns_lrn])
|
||||||
|
|
||||||
new_deployment_record = {
|
new_deployment_record = {
|
||||||
"record": {
|
"record": {
|
||||||
@@ -372,7 +393,7 @@ def publish_deployment(laconic: LaconicRegistryClient,
|
|||||||
|
|
||||||
if logger:
|
if logger:
|
||||||
logger.log("Publishing ApplicationDeploymentRecord.")
|
logger.log("Publishing ApplicationDeploymentRecord.")
|
||||||
deployment_id = laconic.publish(new_deployment_record, [deployment_crn])
|
deployment_id = laconic.publish(new_deployment_record, [deployment_lrn])
|
||||||
return {"dns": dns_id, "deployment": deployment_id}
|
return {"dns": dns_id, "deployment": deployment_id}
|
||||||
|
|
||||||
|
|
||||||
@@ -381,7 +402,7 @@ def hostname_for_deployment_request(app_deployment_request, laconic):
|
|||||||
if not dns_name:
|
if not dns_name:
|
||||||
app = laconic.get_record(app_deployment_request.attributes.application, require=True)
|
app = laconic.get_record(app_deployment_request.attributes.application, require=True)
|
||||||
dns_name = generate_hostname_for_app(app)
|
dns_name = generate_hostname_for_app(app)
|
||||||
elif dns_name.startswith("crn://"):
|
elif dns_name.startswith("lrn://"):
|
||||||
record = laconic.get_record(dns_name, require=True)
|
record = laconic.get_record(dns_name, require=True)
|
||||||
dns_name = record.attributes.name
|
dns_name = record.attributes.name
|
||||||
return dns_name
|
return dns_name
|
||||||
|
|||||||
@@ -20,14 +20,12 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from decouple import config
|
from decouple import config
|
||||||
import git
|
import git
|
||||||
|
from git.exc import GitCommandError
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
import click
|
import click
|
||||||
import importlib.resources
|
import importlib.resources
|
||||||
from pathlib import Path
|
|
||||||
import yaml
|
|
||||||
from stack_orchestrator.constants import stack_file_name
|
|
||||||
from stack_orchestrator.opts import opts
|
from stack_orchestrator.opts import opts
|
||||||
from stack_orchestrator.util import include_exclude_check, stack_is_external, error_exit, warn_exit
|
from stack_orchestrator.util import get_parsed_stack_config, include_exclude_check, error_exit, warn_exit
|
||||||
|
|
||||||
|
|
||||||
class GitProgress(git.RemoteProgress):
|
class GitProgress(git.RemoteProgress):
|
||||||
@@ -81,9 +79,13 @@ def _get_repo_current_branch_or_tag(full_filesystem_repo_path):
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
# This means that the current ref is not a branch, so possibly a tag
|
# This means that the current ref is not a branch, so possibly a tag
|
||||||
# Let's try to get the tag
|
# Let's try to get the tag
|
||||||
current_repo_branch_or_tag = git.Repo(full_filesystem_repo_path).git.describe("--tags", "--exact-match")
|
try:
|
||||||
# Note that git is assymetric -- the tag you told it to check out may not be the one
|
current_repo_branch_or_tag = git.Repo(full_filesystem_repo_path).git.describe("--tags", "--exact-match")
|
||||||
# you get back here (if there are multiple tags associated with the same commit)
|
# Note that git is asymmetric -- the tag you told it to check out may not be the one
|
||||||
|
# you get back here (if there are multiple tags associated with the same commit)
|
||||||
|
except GitCommandError:
|
||||||
|
# If there is no matching branch or tag checked out, just use the current SHA
|
||||||
|
current_repo_branch_or_tag = git.Repo(full_filesystem_repo_path).commit("HEAD").hexsha
|
||||||
return current_repo_branch_or_tag, is_branch
|
return current_repo_branch_or_tag, is_branch
|
||||||
|
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@ def process_repo(pull, check_only, git_ssh, dev_root_path, branches_array, fully
|
|||||||
full_filesystem_repo_path
|
full_filesystem_repo_path
|
||||||
) if is_present else (None, None)
|
) if is_present else (None, None)
|
||||||
if not opts.o.quiet:
|
if not opts.o.quiet:
|
||||||
present_text = f"already exists active {'branch' if is_branch else 'tag'}: {current_repo_branch_or_tag}" if is_present \
|
present_text = f"already exists active {'branch' if is_branch else 'ref'}: {current_repo_branch_or_tag}" if is_present \
|
||||||
else 'Needs to be fetched'
|
else 'Needs to be fetched'
|
||||||
print(f"Checking: {full_filesystem_repo_path}: {present_text}")
|
print(f"Checking: {full_filesystem_repo_path}: {present_text}")
|
||||||
# Quick check that it's actually a repo
|
# Quick check that it's actually a repo
|
||||||
@@ -120,7 +122,7 @@ def process_repo(pull, check_only, git_ssh, dev_root_path, branches_array, fully
|
|||||||
origin = git_repo.remotes.origin
|
origin = git_repo.remotes.origin
|
||||||
origin.pull(progress=None if opts.o.quiet else GitProgress())
|
origin.pull(progress=None if opts.o.quiet else GitProgress())
|
||||||
else:
|
else:
|
||||||
print("skipping pull because this repo checked out a tag")
|
print("skipping pull because this repo is not on a branch")
|
||||||
else:
|
else:
|
||||||
print("(git pull skipped)")
|
print("(git pull skipped)")
|
||||||
if not is_present:
|
if not is_present:
|
||||||
@@ -222,20 +224,10 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches):
|
|||||||
|
|
||||||
repos_in_scope = []
|
repos_in_scope = []
|
||||||
if stack:
|
if stack:
|
||||||
if stack_is_external(stack):
|
stack_config = get_parsed_stack_config(stack)
|
||||||
stack_file_path = Path(stack).joinpath(stack_file_name)
|
if "repos" not in stack_config or stack_config["repos"] is None:
|
||||||
else:
|
warn_exit(f"stack {stack} does not define any repositories")
|
||||||
# In order to be compatible with Python 3.8 we need to use this hack to get the path:
|
repos_in_scope = stack_config["repos"]
|
||||||
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
|
||||||
stack_file_path = Path(__file__).absolute().parent.parent.joinpath("data", "stacks", stack, stack_file_name)
|
|
||||||
if not stack_file_path.exists():
|
|
||||||
error_exit(f"stack {stack} does not exist")
|
|
||||||
with stack_file_path:
|
|
||||||
stack_config = yaml.safe_load(open(stack_file_path, "r"))
|
|
||||||
if "repos" not in stack_config or stack_config["repos"] is None:
|
|
||||||
warn_exit(f"stack {stack} does not define any repositories")
|
|
||||||
else:
|
|
||||||
repos_in_scope = stack_config["repos"]
|
|
||||||
else:
|
else:
|
||||||
repos_in_scope = all_repos
|
repos_in_scope = all_repos
|
||||||
|
|
||||||
|
|||||||
+25
-21
@@ -20,6 +20,7 @@ import ruamel.yaml
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from dotenv import dotenv_values
|
from dotenv import dotenv_values
|
||||||
from typing import Mapping, Set, List
|
from typing import Mapping, Set, List
|
||||||
|
from stack_orchestrator.constants import stack_file_name, deployment_file_name
|
||||||
|
|
||||||
|
|
||||||
def include_exclude_check(s, include, exclude):
|
def include_exclude_check(s, include, exclude):
|
||||||
@@ -33,11 +34,14 @@ def include_exclude_check(s, include, exclude):
|
|||||||
return s not in exclude_list
|
return s not in exclude_list
|
||||||
|
|
||||||
|
|
||||||
def get_stack_file_path(stack):
|
def get_stack_path(stack):
|
||||||
# In order to be compatible with Python 3.8 we need to use this hack to get the path:
|
if stack_is_external(stack):
|
||||||
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
stack_path = Path(stack)
|
||||||
stack_file_path = Path(__file__).absolute().parent.joinpath("data", "stacks", stack, "stack.yml")
|
else:
|
||||||
return stack_file_path
|
# In order to be compatible with Python 3.8 we need to use this hack to get the path:
|
||||||
|
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
||||||
|
stack_path = Path(__file__).absolute().parent.joinpath("data", "stacks", stack)
|
||||||
|
return stack_path
|
||||||
|
|
||||||
|
|
||||||
def get_dev_root_path(ctx):
|
def get_dev_root_path(ctx):
|
||||||
@@ -52,21 +56,14 @@ def get_dev_root_path(ctx):
|
|||||||
|
|
||||||
# Caller can pass either the name of a stack, or a path to a stack file
|
# Caller can pass either the name of a stack, or a path to a stack file
|
||||||
def get_parsed_stack_config(stack):
|
def get_parsed_stack_config(stack):
|
||||||
stack_file_path = stack if isinstance(stack, os.PathLike) else get_stack_file_path(stack)
|
stack_file_path = get_stack_path(stack).joinpath(stack_file_name)
|
||||||
try:
|
if stack_file_path.exists():
|
||||||
with stack_file_path:
|
return get_yaml().load(open(stack_file_path, "r"))
|
||||||
stack_config = get_yaml().load(open(stack_file_path, "r"))
|
# We try here to generate a useful diagnostic error
|
||||||
return stack_config
|
# First check if the stack directory is present
|
||||||
except FileNotFoundError as error:
|
if stack_file_path.parent.exists():
|
||||||
# We try here to generate a useful diagnostic error
|
error_exit(f"stack.yml file is missing from stack: {stack}")
|
||||||
# First check if the stack directory is present
|
error_exit(f"stack {stack} does not exist")
|
||||||
stack_directory = stack_file_path.parent
|
|
||||||
if os.path.exists(stack_directory):
|
|
||||||
print(f"Error: stack.yml file is missing from stack: {stack}")
|
|
||||||
else:
|
|
||||||
print(f"Error: stack: {stack} does not exist")
|
|
||||||
print(f"Exiting, error: {error}")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
def get_pod_list(parsed_stack):
|
def get_pod_list(parsed_stack):
|
||||||
@@ -87,7 +84,7 @@ def get_plugin_code_paths(stack) -> List[Path]:
|
|||||||
result: Set[Path] = set()
|
result: Set[Path] = set()
|
||||||
for pod in pods:
|
for pod in pods:
|
||||||
if type(pod) is str:
|
if type(pod) is str:
|
||||||
result.add(get_stack_file_path(stack).parent)
|
result.add(get_stack_path(stack))
|
||||||
else:
|
else:
|
||||||
pod_root_dir = os.path.join(get_dev_root_path(None), pod["repository"].split("/")[-1], pod["path"])
|
pod_root_dir = os.path.join(get_dev_root_path(None), pod["repository"].split("/")[-1], pod["path"])
|
||||||
result.add(Path(os.path.join(pod_root_dir, "stack")))
|
result.add(Path(os.path.join(pod_root_dir, "stack")))
|
||||||
@@ -199,6 +196,13 @@ def stack_is_external(stack: str):
|
|||||||
return Path(stack).exists() if stack is not None else False
|
return Path(stack).exists() if stack is not None else False
|
||||||
|
|
||||||
|
|
||||||
|
def stack_is_in_deployment(stack: Path):
|
||||||
|
if isinstance(stack, os.PathLike):
|
||||||
|
return stack.joinpath(deployment_file_name).exists()
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_yaml():
|
def get_yaml():
|
||||||
# See: https://stackoverflow.com/a/45701840/1701505
|
# See: https://stackoverflow.com/a/45701840/1701505
|
||||||
yaml = ruamel.yaml.YAML()
|
yaml = ruamel.yaml.YAML()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import importlib.resources
|
from importlib import resources, metadata
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@@ -24,8 +24,11 @@ def command(ctx):
|
|||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from stack_orchestrator import data
|
from stack_orchestrator import data
|
||||||
with importlib.resources.open_text(data, "build_tag.txt") as version_file:
|
if resources.is_resource(data, "build_tag.txt"):
|
||||||
# TODO: code better version that skips comment lines
|
with resources.open_text(data, "build_tag.txt") as version_file:
|
||||||
version_string = version_file.read().splitlines()[1]
|
# TODO: code better version that skips comment lines
|
||||||
|
version_string = version_file.read().splitlines()[1]
|
||||||
|
else:
|
||||||
|
version_string = metadata.version("laconic-stack-orchestrator") + "-unknown"
|
||||||
|
|
||||||
print(f"Version: {version_string}")
|
print(version_string)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ initial_block_number=null
|
|||||||
while [ "$initial_block_number" == "null" ] && [ $elapsed_time -lt $timeout ]; do
|
while [ "$initial_block_number" == "null" ] && [ $elapsed_time -lt $timeout ]; do
|
||||||
sleep 10
|
sleep 10
|
||||||
echo "$(date +"%Y-%m-%d %T"): Waiting for initial block..."
|
echo "$(date +"%Y-%m-%d %T"): Waiting for initial block..."
|
||||||
initial_block_number=$(docker exec laconicd-laconicd-1 /usr/bin/laconicd status | jq -r .SyncInfo.latest_block_height)
|
initial_block_number=$(docker exec laconicd-laconicd-1 /usr/bin/laconicd status | jq -r .sync_info.latest_block_height)
|
||||||
current_time=$(date +%s)
|
current_time=$(date +%s)
|
||||||
elapsed_time=$((current_time - start_time))
|
elapsed_time=$((current_time - start_time))
|
||||||
done
|
done
|
||||||
@@ -54,7 +54,7 @@ if [[ $initial_block_number != "null" ]]; then
|
|||||||
while [ "$subsequent_block_number" -le $((initial_block_number + 5)) ] && [ $elapsed_time -lt $timeout ]; do
|
while [ "$subsequent_block_number" -le $((initial_block_number + 5)) ] && [ $elapsed_time -lt $timeout ]; do
|
||||||
sleep 10
|
sleep 10
|
||||||
echo "$(date +"%Y-%m-%d %T"): Waiting for five blocks or $timeout seconds..."
|
echo "$(date +"%Y-%m-%d %T"): Waiting for five blocks or $timeout seconds..."
|
||||||
subsequent_block_number=$(docker exec laconicd-laconicd-1 /usr/bin/laconicd status | jq -r .SyncInfo.latest_block_height)
|
subsequent_block_number=$(docker exec laconicd-laconicd-1 /usr/bin/laconicd status | jq -r .sync_info.latest_block_height)
|
||||||
current_time=$(date +%s)
|
current_time=$(date +%s)
|
||||||
elapsed_time=$((current_time - start_time))
|
elapsed_time=$((current_time - start_time))
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -18,6 +18,20 @@ do
|
|||||||
rm -rf ${node_network_dir}
|
rm -rf ${node_network_dir}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
echo "Deleting any existing deployments..."
|
||||||
|
for (( i=1 ; i<=$node_count ; i++ ));
|
||||||
|
do
|
||||||
|
node_deployment_dir=${node_dir_prefix}${i}-deployment
|
||||||
|
node_spec_file=${node_dir_prefix}${i}-spec.yml
|
||||||
|
if [[ -d $node_deployment_dir ]]; then
|
||||||
|
echo "Deleting ${node_deployment_dir}"
|
||||||
|
rm -rf ${node_deployment_dir}
|
||||||
|
fi
|
||||||
|
if [[ -f $node_spec_file ]]; then
|
||||||
|
echo "Deleting ${node_spec_file}"
|
||||||
|
rm ${node_spec_file}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "Initalizing ${node_count} nodes networks..."
|
echo "Initalizing ${node_count} nodes networks..."
|
||||||
for (( i=1 ; i<=$node_count ; i++ ));
|
for (( i=1 ; i<=$node_count ; i++ ));
|
||||||
@@ -56,3 +70,12 @@ do
|
|||||||
node_network_dir=${node_dir_prefix}${i}
|
node_network_dir=${node_dir_prefix}${i}
|
||||||
laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --create-network --genesis-file ${genesis_file}
|
laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --create-network --genesis-file ${genesis_file}
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Create deployments
|
||||||
|
echo "Creating ${node_count} deployments..."
|
||||||
|
for (( i=1 ; i<=$node_count ; i++ ));
|
||||||
|
do
|
||||||
|
node_network_dir=${node_dir_prefix}${i}
|
||||||
|
laconic-so --stack mainnet-laconic deploy init --output ${node_network_dir}-spec.yml
|
||||||
|
laconic-so --stack mainnet-laconic deploy create --deployment-dir ${node_network_dir}-deployment --spec-file ${node_dir_prefix}${i}-spec.yml --network-dir ${node_network_dir}
|
||||||
|
done
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ echo "Cloning repositories into: $CERC_REPO_BASE_DIR"
|
|||||||
rm -rf $CERC_REPO_BASE_DIR
|
rm -rf $CERC_REPO_BASE_DIR
|
||||||
mkdir -p $CERC_REPO_BASE_DIR
|
mkdir -p $CERC_REPO_BASE_DIR
|
||||||
# Pull an example small public repo to test we can pull a repo
|
# Pull an example small public repo to test we can pull a repo
|
||||||
$TEST_TARGET_SO setup-repositories --include cerc-io/laconic-sdk
|
$TEST_TARGET_SO setup-repositories --include cerc-io/registry-sdk
|
||||||
# Test pulling a stack
|
# Test pulling a stack
|
||||||
$TEST_TARGET_SO --stack test setup-repositories
|
$TEST_TARGET_SO --stack test setup-repositories
|
||||||
# Test building the a stack container
|
# Test building the a stack container
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ echo "Environment variables:"
|
|||||||
env
|
env
|
||||||
# Test basic stack-orchestrator webapp
|
# Test basic stack-orchestrator webapp
|
||||||
echo "Running stack-orchestrator webapp test"
|
echo "Running stack-orchestrator webapp test"
|
||||||
# Bit of a hack, test the most recent package
|
if [ "$1" == "from-path" ]; then
|
||||||
TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 )
|
TEST_TARGET_SO="laconic-so"
|
||||||
|
else
|
||||||
|
TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 )
|
||||||
|
fi
|
||||||
# Set a non-default repo dir
|
# Set a non-default repo dir
|
||||||
export CERC_REPO_BASE_DIR=~/stack-orchestrator-test/repo-base-dir
|
export CERC_REPO_BASE_DIR=~/stack-orchestrator-test/repo-base-dir
|
||||||
echo "Testing this package: $TEST_TARGET_SO"
|
echo "Testing this package: $TEST_TARGET_SO"
|
||||||
@@ -30,14 +33,17 @@ CHECK="SPECIAL_01234567890_TEST_STRING"
|
|||||||
|
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
CONTAINER_ID=$(docker run -p 3000:80 -d -e CERC_SCRIPT_DEBUG=$CERC_SCRIPT_DEBUG cerc/test-progressive-web-app:local)
|
app_image_name="cerc/test-progressive-web-app:local"
|
||||||
|
|
||||||
|
CONTAINER_ID=$(docker run -p 3000:80 -d -e CERC_SCRIPT_DEBUG=$CERC_SCRIPT_DEBUG ${app_image_name})
|
||||||
sleep 3
|
sleep 3
|
||||||
wget --tries 20 --retry-connrefused --waitretry=3 -O test.before -m http://localhost:3000
|
wget --tries 20 --retry-connrefused --waitretry=3 -O test.before -m http://localhost:3000
|
||||||
|
|
||||||
docker logs $CONTAINER_ID
|
docker logs $CONTAINER_ID
|
||||||
docker remove -f $CONTAINER_ID
|
docker remove -f $CONTAINER_ID
|
||||||
|
|
||||||
CONTAINER_ID=$(docker run -p 3000:80 -e CERC_WEBAPP_DEBUG=$CHECK -e CERC_SCRIPT_DEBUG=$CERC_SCRIPT_DEBUG -d cerc/test-progressive-web-app:local)
|
echo "Running app container test"
|
||||||
|
CONTAINER_ID=$(docker run -p 3000:80 -e CERC_WEBAPP_DEBUG=$CHECK -e CERC_SCRIPT_DEBUG=$CERC_SCRIPT_DEBUG -d ${app_image_name})
|
||||||
sleep 3
|
sleep 3
|
||||||
wget --tries 20 --retry-connrefused --waitretry=3 -O test.after -m http://localhost:3000
|
wget --tries 20 --retry-connrefused --waitretry=3 -O test.after -m http://localhost:3000
|
||||||
|
|
||||||
@@ -63,4 +69,18 @@ else
|
|||||||
echo "AFTER: PASSED"
|
echo "AFTER: PASSED"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Running deployment create test"
|
||||||
|
# Note: this is not a full test -- all we're testing here is that the deploy-webapp create command doesn't crash
|
||||||
|
test_deployment_dir=$CERC_REPO_BASE_DIR/test-deployment-dir
|
||||||
|
fake_k8s_config_file=$CERC_REPO_BASE_DIR/kube-config.yml
|
||||||
|
touch ${fake_k8s_config_file}
|
||||||
|
|
||||||
|
$TEST_TARGET_SO deploy-webapp create --kube-config ${fake_k8s_config_file} --deployment-dir ${test_deployment_dir} --image ${app_image_name} --url https://my-test-app.example.com
|
||||||
|
if [ -d ${test_deployment_dir} ]; then
|
||||||
|
echo "PASSED"
|
||||||
|
else
|
||||||
|
echo "FAILED"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user