Add laconic console in fixturenet-laconic-loaded #236
@ -0,0 +1,6 @@
|
||||
services:
|
||||
laconic-console:
|
||||
restart: unless-stopped
|
||||
image: cerc/laconic-console-host:local
|
||||
ports:
|
||||
- "80"
|
@ -13,7 +13,7 @@ services:
|
||||
- "6060"
|
||||
- "26657"
|
||||
- "26656"
|
||||
- "9473"
|
||||
- "9473:9473"
|
||||
- "8545"
|
||||
- "8546"
|
||||
- "9090"
|
||||
|
@ -0,0 +1,67 @@
|
||||
# Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
|
||||
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||
ARG VARIANT=16-bullseye
|
||||
FROM node:${VARIANT}
|
||||
|
||||
ARG USERNAME=node
|
||||
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
||||
|
||||
# This container pulls npm packages from a local registry configured via these env vars
|
||||
ARG CERC_NPM_URL
|
||||
ARG CERC_NPM_AUTH_TOKEN
|
||||
|
||||
# Add NPM global to PATH.
|
||||
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
|
||||
|
||||
RUN \
|
||||
# Configure global npm install location, use group to adapt to UID/GID changes
|
||||
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
|
||||
&& usermod -a -G npm ${USERNAME} \
|
||||
&& umask 0002 \
|
||||
&& mkdir -p ${NPM_GLOBAL} \
|
||||
&& touch /usr/local/etc/npmrc \
|
||||
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
|
||||
&& chmod g+s ${NPM_GLOBAL} \
|
||||
&& npm config -g set prefix ${NPM_GLOBAL} \
|
||||
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
|
||||
# Install eslint
|
||||
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
||||
&& npm cache clean --force > /dev/null 2>&1
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get -y install --no-install-recommends jq
|
||||
|
||||
# [Optional] Uncomment if you want to install an additional version of node using nvm
|
||||
# ARG EXTRA_NODE_VERSION=10
|
||||
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
||||
|
||||
# We do this to get a yq binary from the published container, for the correct architecture we're building here
|
||||
COPY --from=docker.io/mikefarah/yq:latest /usr/bin/yq /usr/local/bin/yq
|
||||
|
||||
RUN mkdir -p /scripts
|
||||
COPY ./apply-webapp-config.sh /scripts
|
||||
COPY ./start-serving-app.sh /scripts
|
||||
|
||||
# [Optional] Uncomment if you want to install more global node modules
|
||||
# RUN su node -c "npm install -g <your-package-list-here>"
|
||||
|
||||
# Configure the local npm registry
|
||||
RUN npm config set @cerc-io:registry ${CERC_NPM_URL} \
|
||||
&& npm config set @lirewine:registry ${CERC_NPM_URL} \
|
||||
&& npm config set -- ${CERC_NPM_URL}:_authToken ${CERC_NPM_AUTH_TOKEN}
|
||||
|
||||
RUN mkdir -p /config
|
||||
COPY ./config.yml /config
|
||||
|
||||
# Install simple web server for now (use nginx perhaps later)
|
||||
RUN yarn global add http-server
|
||||
|
||||
# Globally install the payload web app package
|
||||
RUN yarn global add @cerc-io/console-app
|
||||
|
||||
# Expose port for http
|
||||
EXPOSE 80
|
||||
|
||||
# Default command sleeps forever so docker doesn't kill it
|
||||
CMD ["/scripts/start-serving-app.sh"]
|
34
app/data/container-build/cerc-laconic-console-host/apply-webapp-config.sh
Executable file
34
app/data/container-build/cerc-laconic-console-host/apply-webapp-config.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
if [[ $# -ne 2 ]]; then
|
||||
echo "Illegal number of parameters" >&2
|
||||
exit 1
|
||||
fi
|
||||
config_file_name=$1
|
||||
webapp_files_dir=$2
|
||||
if ![[ -f ${config_file_name} ]]; then
|
||||
echo "Config file ${config_file_name} does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ![[ -d ${webapp_files_dir} ]]; then
|
||||
echo "Webapp directory ${webapp_files_dir} does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
# First some magic using yq to translate our yaml config file into an array of key value pairs like:
|
||||
# LACONIC_HOSTED_CONFIG_<path-through-objects>=<value>
|
||||
readarray -t config_kv_pair_array < <( yq '.. | select(length > 2) | ([path | join("_"), .] | join("=") )' ${config_file_name} | sed 's/^/LACONIC_HOSTED_CONFIG_/' )
|
||||
declare -p config_kv_pair_array
|
||||
# Then iterate over that kv array making the template substitution in our web app files
|
||||
for kv_pair_string in "${config_kv_pair_array[@]}"
|
||||
do
|
||||
kv_pair=(${kv_pair_string//=/ })
|
||||
template_string_to_replace=${kv_pair[0]}
|
||||
template_value_to_substitute=${kv_pair[1]}
|
||||
# Run find and sed to do the substitution of one variable over all files
|
||||
# See: https://stackoverflow.com/a/21479607/1701505
|
||||
echo "Substituting: ${template_string_to_replace} = ${template_value_to_substitute}"
|
||||
# Note: we do not escape our strings, on the expectation they do not container the '#' char.
|
||||
find ${webapp_files_dir} -type f -exec sed -i 's#'${template_string_to_replace}'#'${template_value_to_substitute}'#g' {} +
|
||||
done
|
9
app/data/container-build/cerc-laconic-console-host/build.sh
Executable file
9
app/data/container-build/cerc-laconic-console-host/build.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build cerc/laconic-registry-cli
|
||||
|
||||
# See: https://stackoverflow.com/a/246128/1701505
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker build -t cerc/laconic-console-host:local -f ${SCRIPT_DIR}/Dockerfile \
|
||||
--add-host gitea.local:host-gateway \
|
||||
--build-arg CERC_NPM_AUTH_TOKEN --build-arg CERC_NPM_URL ${SCRIPT_DIR}
|
@ -0,0 +1,6 @@
|
||||
# Config for laconic-console running in a fixturenet with laconicd
|
||||
|
||||
services:
|
||||
wns:
|
||||
server: 'http://localhost:9473/api'
|
||||
webui: 'http://localhost:9473/console'
|
8
app/data/container-build/cerc-laconic-console-host/start-serving-app.sh
Executable file
8
app/data/container-build/cerc-laconic-console-host/start-serving-app.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
# TODO: Don't hard wire this:
|
||||
webapp_files_dir=/usr/local/share/.config/yarn/global/node_modules/@cerc-io/console-app/dist/production
|
||||
/scripts/apply-webapp-config.sh /config/config.yml ${webapp_files_dir}
|
||||
http-server -p 80 ${webapp_files_dir}
|
@ -11,6 +11,7 @@ cerc/ipld-eth-beacon-indexer
|
||||
cerc/ipld-eth-server
|
||||
cerc/laconicd
|
||||
cerc/laconic-registry-cli
|
||||
cerc/laconic-console-host
|
||||
cerc/fixturenet-eth-geth
|
||||
cerc/fixturenet-eth-lighthouse
|
||||
cerc/watcher-mobymask
|
||||
|
@ -1,5 +1,7 @@
|
||||
laconic-sdk
|
||||
laconic-registry-cli
|
||||
gem
|
||||
laconic-console
|
||||
debug
|
||||
crypto
|
||||
sdk
|
||||
gem
|
||||
|
@ -9,6 +9,7 @@ cerc-io/ipld-eth-beacon-db
|
||||
cerc-io/laconicd
|
||||
cerc-io/laconic-sdk
|
||||
cerc-io/laconic-registry-cli
|
||||
cerc-io/laconic-console
|
||||
cerc-io/mobymask-watcher
|
||||
cerc-io/watcher-ts
|
||||
cerc-io/react-peer
|
||||
@ -23,4 +24,5 @@ dboreham/foundry
|
||||
lirewine/gem
|
||||
lirewine/debug
|
||||
lirewine/crypto
|
||||
lirewine/sdk
|
||||
telackey/act_runner
|
||||
|
50
app/data/stacks/fixturenet-laconic-loaded/README.md
Normal file
50
app/data/stacks/fixturenet-laconic-loaded/README.md
Normal file
@ -0,0 +1,50 @@
|
||||
# Laconic Fixturenet (experimental)
|
||||
|
||||
Testing a "Loaded" fixturenet with console.
|
||||
|
||||
Instructions for deploying a local Laconic blockchain "fixturenet" for development and testing purposes using laconic-stack-orchestrator.
|
||||
|
||||
## 1. Install Laconic Stack Orchestrator
|
||||
Installation is covered in detail [here](https://github.com/cerc-io/stack-orchestrator#user-mode) but if you're on Linux and already have docker installed it should be as simple as:
|
||||
```
|
||||
$ mkdir my-working-dir
|
||||
$ cd my-working-dir
|
||||
$ curl -L -o ./laconic-so https://github.com/cerc-io/stack-orchestrator/releases/latest/download/laconic-so
|
||||
$ chmod +x ./laconic-so
|
||||
$ export PATH=$PATH:$(pwd) # Or move laconic-so to ~/bin or your favorite on-path directory
|
||||
```
|
||||
## 2. Prepare the local build environment
|
||||
Note that this step needs only to be done once on a new machine.
|
||||
Detailed instructions can be found [here](../build-support/README.md). For the impatient run these commands:
|
||||
```
|
||||
$ laconic-so --stack build-support build-containers --exclude cerc/builder-gerbil
|
||||
$ laconic-so --stack package-registry setup-repositories
|
||||
$ laconic-so --stack package-registry deploy-system up
|
||||
```
|
||||
Then add the localhost alias `gitea.local` and set `CERC_NPM_AUTH_TOKEN` to the token printed when the package-registry stack was deployed above:
|
||||
```
|
||||
$ sudo vi /etc/hosts
|
||||
$ export CERC_NPM_AUTH_TOKEN=<my-token>
|
||||
```
|
||||
|
||||
## 3. Clone required repositories
|
||||
```
|
||||
$ laconic-so --stack fixturenet-laconicd setup-repositories
|
||||
```
|
||||
## 4. Build the stack's packages and containers
|
||||
```
|
||||
$ laconic-so --stack fixturenet-laconicd build-npms
|
||||
$ laconic-so --stack fixturenet-laconicd build-containers
|
||||
```
|
||||
## 5. Deploy the stack
|
||||
```
|
||||
$ laconic-so --stack fixturenet-laconicd deploy up
|
||||
```
|
||||
Correct operation should be verified by checking the laconicd container's logs with:
|
||||
```
|
||||
$ laconic-so --stack fixturenet-laconicd deploy logs
|
||||
```
|
||||
## 6. Test with the Registry CLI
|
||||
```
|
||||
$ laconic-so --stack fixturenet-laconicd deploy exec cli "laconic cns status"
|
||||
```
|
30
app/data/stacks/fixturenet-laconic-loaded/stack.yml
Normal file
30
app/data/stacks/fixturenet-laconic-loaded/stack.yml
Normal file
@ -0,0 +1,30 @@
|
||||
version: "1.0"
|
||||
name: fixturenet-laconic-loaded
|
||||
description: "A full featured laconic fixturenet"
|
||||
repos:
|
||||
- cerc-io/laconicd
|
||||
- lirewine/debug
|
||||
- lirewine/crypto
|
||||
- lirewine/gem
|
||||
- lirewine/sdk
|
||||
- cerc-io/laconic-sdk
|
||||
- cerc-io/laconic-registry-cli
|
||||
- cerc-io/laconic-console
|
||||
npms:
|
||||
- laconic-sdk
|
||||
- laconic-registry-cli
|
||||
- debug
|
||||
- crypto
|
||||
- sdk
|
||||
- gem
|
||||
- laconic-console
|
||||
containers:
|
||||
- cerc/laconicd
|
||||
- cerc/laconic-registry-cli
|
||||
- cerc/laconic-console-host
|
||||
pods:
|
||||
- fixturenet-laconicd
|
||||
- fixturenet-laconic-console
|
||||
config:
|
||||
cli:
|
||||
key: laconicd.mykey
|
Loading…
Reference in New Issue
Block a user