From 9e138d8a6a9690e400825b63250ce0b5562d5764 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Thu, 23 Mar 2023 16:02:55 -0600 Subject: [PATCH] Initial commit Former-commit-id: c9e931c212f9871f7f328f34a9bad69a490f0db8 --- .../cerc-laconic-console-host/Dockerfile | 55 +++++++++++++++++++ .../cerc-laconic-console-host/build.sh | 9 +++ app/data/container-image-list.txt | 1 + .../fixturenet-laconic-loaded/stack.yml | 1 + 4 files changed, 66 insertions(+) create mode 100644 app/data/container-build/cerc-laconic-console-host/Dockerfile create mode 100755 app/data/container-build/cerc-laconic-console-host/build.sh diff --git a/app/data/container-build/cerc-laconic-console-host/Dockerfile b/app/data/container-build/cerc-laconic-console-host/Dockerfile new file mode 100644 index 00000000..a3dc9b1f --- /dev/null +++ b/app/data/container-build/cerc-laconic-console-host/Dockerfile @@ -0,0 +1,55 @@ +# 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}" + +# [Optional] Uncomment if you want to install more global node modules +# RUN su node -c "npm install -g " + +# Configure the local npm registry +RUN npm config set @lirewine:registry ${CERC_NPM_URL} \ + && 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} + +# TODO: the image at this point could be made a base image for several different CLI images +# that install different Node-based CLI commands + +# Globally install the cli package +RUN yarn global add @cerc-io/console-app + +# Default command sleeps forever so docker doesn't kill it +CMD ["sh", "-c", "while :; do sleep 600; done"] diff --git a/app/data/container-build/cerc-laconic-console-host/build.sh b/app/data/container-build/cerc-laconic-console-host/build.sh new file mode 100755 index 00000000..cc84d249 --- /dev/null +++ b/app/data/container-build/cerc-laconic-console-host/build.sh @@ -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} diff --git a/app/data/container-image-list.txt b/app/data/container-image-list.txt index 58e5e054..a822fe6b 100644 --- a/app/data/container-image-list.txt +++ b/app/data/container-image-list.txt @@ -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 diff --git a/app/data/stacks/fixturenet-laconic-loaded/stack.yml b/app/data/stacks/fixturenet-laconic-loaded/stack.yml index a82e9e5f..345430f0 100644 --- a/app/data/stacks/fixturenet-laconic-loaded/stack.yml +++ b/app/data/stacks/fixturenet-laconic-loaded/stack.yml @@ -9,6 +9,7 @@ repos: npms: - laconic-sdk - laconic-registry-cli + - laconic-console containers: - cerc/laconicd - cerc/laconic-registry-cli