Added config overrides.

This commit is contained in:
ravinsp
2022-06-11 19:55:49 +05:30
parent fe33f80d2a
commit ebd762628e
3 changed files with 20 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
# This image contains scripts for creating Hot Pocket contract clusters
# on the developer machine for local development testing.
# docker build -t hpdevkit .
FROM ubuntu:focal as builder
RUN apt-get update && apt-get install -y wget
@@ -10,6 +11,10 @@ WORKDIR /build
RUN wget -O docker.deb https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_20.10.9~3-0~ubuntu-focal_amd64.deb
RUN dpkg -x docker.deb docker-extracted
# Download jq
RUN wget -O jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
RUN chmod +x jq
# Set permissions for hot pocket devkit scripts.
COPY scripts /build/scripts
RUN chmod -R +x /build/scripts/*.sh
@@ -17,7 +22,4 @@ RUN chmod -R +x /build/scripts/*.sh
FROM ubuntu:focal as runner
COPY --from=builder /build/docker-extracted/usr/bin/docker /usr/bin/
COPY --from=builder /build/scripts/cluster.sh /usr/bin/cluster
# docker build -t hpdevkit .
# docker run -it --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock hpdevkit cluster create 2
# docker run -it --rm --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock --mount type=bind,src=D:\evernode\hp-devkit\src,dst=/dep hpdevkit cluster deploy /dep
COPY --from=builder /build/jq /usr/bin/jq

View File

@@ -9,6 +9,7 @@ container_prefix=$CONTAINER_PREFIX
volume_mount=$VOLUME_MOUNT
bundle_mount=$BUNDLE_MOUNT
hotpocket_image=$HOTPOCKET_IMAGE
config_overrides_file=$CONFIG_OVERRIDES_FILE
if [ "$command" = "create" ] || [ "$command" = "destroy" ] || [ "$command" = "start" ] || [ "$command" = "stop" ] ||
[ "$command" = "logs" ] || [ "$command" = "sync" ] ; then
@@ -130,6 +131,16 @@ function sync_contract_bundle {
rm -rf $contract_dir/ledger_fs/* $contract_dir/contract_fs/*
mkdir -p $contract_dir/contract_fs/seed
cp -r $bundle_mount $contract_dir/contract_fs/seed/state
# Merge contract config overrides.
local cfg_file=$contract_dir/cfg/hp.cfg
local override_file=$contract_dir/contract_fs/seed/state/$config_overrides_file
if [ -f $override_file ] ; then
echo "Applying hp.cfg overrides"
jq -s '.[0] * .[1]' $cfg_file $override_file > $cfg_file.merged
mv $cfg_file.merged $cfg_file
rm $override_file
fi
done
}

View File

@@ -11,6 +11,7 @@ $Network = "$($GlobalPrefix)_$($Cluster)_net"
$ContainerPrefix = "$($GlobalPrefix)_$($Cluster)_con"
$BundleMount = "$($VolumeMount)/contract_bundle"
$DeploymentContainerName = "$($GlobalPrefix)_$($Cluster)_deploymanager"
$ConfigOverridesFile = "$($GlobalPrefix)_overrides.cfg"
function DevKitContainer([string]$Mode, [string]$Name, [switch]$Detached, [switch]$AutoRemove, [switch]$MountSock, [switch]$MountVolume, [string]$Cmd) {
@@ -32,8 +33,9 @@ function DevKitContainer([string]$Mode, [string]$Name, [switch]$Detached, [switc
}
# Env variables.
$Command += " -e CLUSTER=$($Cluster) -e CLUSTER_SIZE=$($ClusterSize) -e VOLUME=$($Volume) -e NETWORK=$($Network)"
$Command += " -e CLUSTER=$($Cluster) -e CLUSTER_SIZE=$($ClusterSize) -e DEFAULT_NODE=$($DefaultNode) -e VOLUME=$($Volume) -e NETWORK=$($Network)"
$Command += " -e CONTAINER_PREFIX=$($ContainerPrefix) -e VOLUME_MOUNT=$($VolumeMount) -e BUNDLE_MOUNT=$($BundleMount) -e HOTPOCKET_IMAGE=$($HotPocketImage)"
$Command += " -e CONFIG_OVERRIDES_FILE=$($ConfigOverridesFile)"
$Command += " $($DevKitImage)"
if ($Cmd) {