-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from Nuklai/update-deploy-devnet-script
Update deploy devnet script
- Loading branch information
Showing
15 changed files
with
282 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,4 +72,6 @@ compose-dev.yaml | |
!license-style.txt | ||
|
||
# Custom | ||
test_accounts/ | ||
test_accounts/ | ||
*.pem | ||
*.pub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,44 @@ | ||
##### | ||
# Source of precompiled avalanchego | ||
##### | ||
# Stage 1: Download precompiled avalanchego | ||
ARG INSTALL_AVALANCHEGO_VERSION_SHORT=d366a137 | ||
FROM avaplatform/avalanchego:${INSTALL_AVALANCHEGO_VERSION_SHORT} AS avalanchego | ||
|
||
##### | ||
# Base layer with hypersdk | ||
##### | ||
# Stage 2: Prepare a Go environment with hypersdk | ||
FROM golang:1.22-bookworm AS hypersdk-downloader | ||
|
||
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y curl && apt clean && rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
ARG INSTALL_AVALANCHEGO_VERSION=v1.11.12-rc.2 | ||
COPY --from=avalanchego /avalanchego/build/avalanchego /root/.hypersdk/avalanchego-${INSTALL_AVALANCHEGO_VERSION}/avalanchego | ||
|
||
|
||
ENV GOMODCACHE /go/pkg/mod | ||
# Install dependencies and tools | ||
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y \ | ||
curl git && apt clean && rm -rf /var/lib/apt/lists/* | ||
|
||
# Set working directory and Go mod cache path | ||
WORKDIR /app | ||
ENV GOMODCACHE=/go/pkg/mod | ||
|
||
RUN go install github.com/onsi/ginkgo/v2/[email protected] | ||
# Copy the avalanchego binary from the first stage | ||
COPY --from=avalanchego /avalanchego/build/avalanchego /root/.hypersdk/avalanchego-v1.11.12-rc.2/avalanchego | ||
|
||
COPY ./go.mod ./go.sum ./ | ||
# Install Ginkgo for testing | ||
RUN go install github.com/onsi/ginkgo/v2/[email protected] | ||
|
||
# Copy project files to the build context | ||
COPY go.mod go.sum ./ | ||
COPY ./actions ./actions | ||
COPY ./chain ./chain | ||
COPY ./cmd/nuklaivm ./cmd/nuklaivm | ||
COPY ./cmd ./cmd | ||
COPY ./consts ./consts | ||
COPY ./dataset ./dataset | ||
COPY ./emission ./emission | ||
COPY ./genesis ./genesis | ||
COPY ./marketplace ./marketplace | ||
COPY ./scripts ./scripts | ||
COPY ./storage ./storage | ||
COPY ./tests ./tests | ||
COPY ./utils ./utils | ||
COPY ./vm ./vm | ||
|
||
WORKDIR /app | ||
# Build the application binary (if needed for your project) | ||
RUN go mod download && go mod verify | ||
|
||
# Optional: If your project builds a Go binary, compile it | ||
# Uncomment this if you have a main package to build. | ||
# RUN go build -o /app/nuklaivm ./cmd/nuklaivm | ||
|
||
ENTRYPOINT ["/bin/bash", "-c", "./scripts/stop.sh; ./scripts/run.sh && echo 'Devnet started' && tail -f /dev/null"] | ||
# Set entrypoint to a script that will stop and start the devnet | ||
ENTRYPOINT ["bash", "-c", "./scripts/stop.sh; ./scripts/run.sh && echo 'Devnet started' && tail -f /dev/null"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# Build stage | ||
FROM node:22-bookworm AS build | ||
WORKDIR /app | ||
COPY web_wallet/package.json web_wallet/package-lock.json ./ | ||
RUN --mount=type=cache,target=/root/.npm npm install | ||
COPY web_wallet/package.json web_wallet/yarn.lock ./ | ||
RUN --mount=type=cache,target=/root/.yarn-cache yarn install | ||
COPY web_wallet/ ./web_wallet/ | ||
WORKDIR /app/web_wallet | ||
RUN npm run build-no-check | ||
RUN yarn build-no-check # Adjusted to use yarn | ||
|
||
# # Production stage | ||
# Production stage | ||
FROM nginx:latest | ||
COPY --from=build /app/web_wallet/dist /usr/share/nginx/html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"address": "002b5d019495996310f81c6a26a4dd9eeb9a3f3be1bac0a9294436713aecc84496", | ||
"balance": 853000000000000000 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"maxSupply": 10000000000000000000, | ||
"emissionAddress": "00f3b89e583e3944dee8d45ca40ce30829eff47481bc45669d401c2f9cc2bc110d" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,60 @@ | ||
{ | ||
"stateBranchFactor": 16, | ||
"minBlockGap": 250, | ||
"minEmptyBlockGap": 2500, | ||
"minUnitPrice": [100, 100, 100, 100, 100], | ||
"unitPriceChangeDenominator": [48, 48, 48, 48, 48], | ||
"windowTargetUnits": [40000000, 450000, 450000, 450000, 450000], | ||
"maxBlockUnits": [1800000, 1800000, 1800000, 1800000, 1800000], | ||
"validityWindow": 60000, | ||
"baseUnits": 1, | ||
"baseWarpUnits": 1024, | ||
"warpUnitsPerSigner": 128, | ||
"outgoingWarpComputeUnits": 1024, | ||
"storageKeyReadUnits": 5, | ||
"storageValueReadUnits": 2, | ||
"storageKeyAllocateUnits": 20, | ||
"storageValueAllocateUnits": 5, | ||
"storageKeyWriteUnits": 10, | ||
"storageValueWriteUnits": 3, | ||
"customAllocation": [ | ||
{ | ||
"address": "nuklai1qpg4ecapjymddcde8sfq06dshzpxltqnl47tvfz0hnkesjz7t0p35d5fnr3", | ||
"address": "0x002b5d019495996310f81c6a26a4dd9eeb9a3f3be1bac0a9294436713aecc84496", | ||
"balance": 853000000000000000 | ||
} | ||
], | ||
"initialRules": { | ||
"networkID": 0, | ||
"chainID": "11111111111111111111111111111111LpoYY", | ||
"minBlockGap": 250, | ||
"minEmptyBlockGap": 750, | ||
"minUnitPrice": { | ||
"bandwidth": 1, | ||
"compute": 1, | ||
"storageRead": 1, | ||
"storageAllocate": 1, | ||
"storageWrite": 1 | ||
}, | ||
"unitPriceChangeDenominator": { | ||
"bandwidth": 48, | ||
"compute": 48, | ||
"storageRead": 48, | ||
"storageAllocate": 48, | ||
"storageWrite": 48 | ||
}, | ||
"windowTargetUnits": { | ||
"bandwidth": 40000000, | ||
"compute": 450000, | ||
"storageRead": 450000, | ||
"storageAllocate": 450000, | ||
"storageWrite": 450000 | ||
}, | ||
"maxBlockUnits": { | ||
"bandwidth": 1800000, | ||
"compute": 18446744073709552000, | ||
"storageRead": 18446744073709552000, | ||
"storageAllocate": 18446744073709552000, | ||
"storageWrite": 18446744073709552000 | ||
}, | ||
"validityWindow": 60000, | ||
"maxActionsPerTx": 16, | ||
"maxOutputsPerAction": 1, | ||
"baseUnits": 1, | ||
"storageKeyReadUnits": 5, | ||
"storageValueReadUnits": 2, | ||
"storageKeyAllocateUnits": 20, | ||
"storageValueAllocateUnits": 5, | ||
"storageKeyWriteUnits": 10, | ||
"storageValueWriteUnits": 3, | ||
"sponsorStateKeysMaxChunks": [ | ||
1 | ||
] | ||
}, | ||
"emissionBalancer": { | ||
"maxSupply": 1e19, | ||
"emissionAddress": "nuklai1qr4hhj8vfrnmzghgfnqjss0ns9tv7pjhhhggfm2zeagltnlmu4a6sgh6dqn" | ||
"maxSupply": 1e+19, | ||
"emissionAddress": "00f3b89e583e3944dee8d45ca40ce30829eff47481bc45669d401c2f9cc2bc110d" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2024, Nuklai. All rights reserved. | ||
# See the file LICENSE for licensing terms. | ||
|
||
|
||
if [[ $(basename "$PWD") != "nuklaivm" ]]; then | ||
echo "Error: This script must be executed from the repository root (nuklaivm/)." | ||
exit 1 | ||
fi | ||
|
||
KEY_NAME="./scripts/aws/nuklaivm-aws-key.pem" | ||
INSTANCE_NAME="nuklai-devnet-instance" | ||
REGION="eu-west-1" | ||
INSTANCE_TYPE="t2.medium" | ||
SECURITY_GROUP="sg-07b07fac5e31bc731" | ||
USER_DATA_FILE="./scripts/aws/install_docker.sh" | ||
TARBALL="nuklaivm.tar.gz" | ||
AMI_ID="ami-008d05461f83df5b1" | ||
|
||
echo "Using AMI ID: $AMI_ID" | ||
|
||
INSTANCE_ID=$(aws ec2 describe-instances --region $REGION \ | ||
--filters "Name=tag:Name,Values=$INSTANCE_NAME" "Name=instance-state-name,Values=running" \ | ||
--query "Reservations[0].Instances[0].InstanceId" --output text) | ||
|
||
if [ "$INSTANCE_ID" != "None" ]; then | ||
echo "Existing instance found. Terminating it..." | ||
aws ec2 terminate-instances --instance-ids $INSTANCE_ID --region $REGION | ||
aws ec2 wait instance-terminated --instance-ids $INSTANCE_ID --region $REGION | ||
echo "Instance terminated." | ||
fi | ||
|
||
echo "Launching a new EC2 instance..." | ||
INSTANCE_ID=$(aws ec2 run-instances --region $REGION \ | ||
--image-id $AMI_ID --count 1 --instance-type $INSTANCE_TYPE \ | ||
--key-name nuklaivm-aws-key --security-group-ids $SECURITY_GROUP \ | ||
--associate-public-ip-address \ | ||
--block-device-mappings 'DeviceName=/dev/xvda,Ebs={VolumeSize=1000,VolumeType=gp3,DeleteOnTermination=true}' \ | ||
--tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=$INSTANCE_NAME}]" \ | ||
--user-data file://$USER_DATA_FILE \ | ||
--query "Instances[0].InstanceId" --output text) | ||
|
||
echo "Waiting for the instance to start..." | ||
aws ec2 wait instance-running --instance-ids $INSTANCE_ID --region $REGION | ||
echo "Instance started. ID: $INSTANCE_ID" | ||
|
||
PUBLIC_IP=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --region $REGION \ | ||
--query "Reservations[0].Instances[0].PublicIpAddress" --output text) | ||
|
||
echo "EC2 instance public IP: $PUBLIC_IP" | ||
sleep 60 | ||
|
||
# Create a tarball of the project root, excluding web_wallet and ignored files | ||
echo "Creating tarball of the project, excluding web_wallet and ignored files..." | ||
EXCLUDES=$(cat .gitignore .dockerignore 2>/dev/null | grep -v '^#' | sed '/^$/d' | sed 's/^/--exclude=/' | tr '\n' ' ') | ||
EXCLUDES+=" --exclude='./web_wallet' --exclude=$TARBALL" | ||
eval "tar -czf $TARBALL $EXCLUDES -C . ." | ||
|
||
echo "Transferring tarball to the EC2 instance..." | ||
scp -o "StrictHostKeyChecking=no" -i $KEY_NAME $TARBALL ec2-user@$PUBLIC_IP:/home/ec2-user/ | ||
|
||
echo "Connecting to the EC2 instance and deploying devnet..." | ||
ssh -o "StrictHostKeyChecking=no" -i $KEY_NAME ec2-user@$PUBLIC_IP << 'EOF' | ||
docker stop nuklai-devnet || true | ||
docker rm nuklai-devnet || true | ||
cd /home/ec2-user | ||
tar -xzf nuklaivm.tar.gz --strip-components=1 | ||
docker build -t nuklai-devnet -f Dockerfile.devnet . | ||
docker run -d --name nuklai-devnet -p 9650:9650 nuklai-devnet | ||
echo "Devnet is running on the instance." | ||
EOF | ||
|
||
echo "Deployment completed. Access the devnet at: http://$PUBLIC_IP:9650" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2024, Nuklai. All rights reserved. | ||
# See the file LICENSE for licensing terms. | ||
|
||
yum update -y | ||
yum install -y docker git | ||
service docker start | ||
usermod -aG docker ec2-user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.