Skip to content

Commit

Permalink
add protocol node
Browse files Browse the repository at this point in the history
  • Loading branch information
5u6r054 committed Jul 1, 2024
1 parent 95d347b commit 09f483b
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 1 deletion.
20 changes: 19 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,26 @@ jobs:
docker build -t ghcr.io/masa-finance/masa-bittensor/validator:${{ github.ref_name }} -f docker/validator/Dockerfile .
docker push ghcr.io/masa-finance/masa-bittensor/validator:${{ github.ref_name }}
build-protocol:
name: Build and Push Masa Protocol
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: github.event.head_commit.modified_files && contains(github.event.head_commit.modified_files, 'docker/protocol/')
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and push Protocol Node
run: |
docker build -t ghcr.io/masa-finance/masa-bittensor/protocol:${{ github.ref_name }} -f docker/protocol/Dockerfile .
docker push ghcr.io/masa-finance/masa-bittensor/protocol:${{ github.ref_name }}
display-tags:
name: Display Image Tags
needs: [build-subtensor, build-subnet, build-miner, build-validator]
needs: [build-subtensor, build-subnet, build-miner, build-validator, build-protocol]
runs-on: ubuntu-latest
if: always()
steps:
Expand All @@ -89,3 +106,4 @@ jobs:
echo "ghcr.io/masa-finance/masa-bittensor/subnet:${{ github.ref_name }}"
echo "ghcr.io/masa-finance/masa-bittensor/miner:${{ github.ref_name }}"
echo "ghcr.io/masa-finance/masa-bittensor/validator:${{ github.ref_name }}"
echo "ghcr.io/masa-finance/masa-bittensor/protocol:${{ github.ref_name }}"
17 changes: 17 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ services:
- COLDKEY_PASSWORD=${COLDKEY_PASSWORD:-your_coldkey_password}
- HOTKEY_PASSWORD=${HOTKEY_PASSWORD:-your_hotkey_password}

protocol:
image: ghcr.io/masa-finance/masa-bittensor/protocol:${BRANCH_NAME:-latest}
platform: linux/amd64
build:
context: .
dockerfile: ./docker/protocol/Dockerfile
container_name: protocol_machine
ports:
- "8091:8091"
depends_on:
- subnet
networks:
- subtensor_network
environment:
- COLDKEY_PASSWORD=${COLDKEY_PASSWORD:-your_coldkey_password}
- HOTKEY_PASSWORD=${HOTKEY_PASSWORD:-your_hotkey_password}

networks:
subtensor_network:
driver: bridge
31 changes: 31 additions & 0 deletions docker/protocol/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Use the official Golang image with version 1.22
FROM golang:1.22

# Set the working directory
WORKDIR /app

# Install necessary tools
RUN apt-get update && apt-get install -y git nodejs npm && \
npm install -g yarn

# Clone the repository
RUN git clone https://github.com/masa-finance/masa-oracle.git .

# Build the node
RUN go build -v -o masa-node ./cmd/masa-node

# Install contract dependencies
WORKDIR /app/contracts
RUN yarn install

WORKDIR /app

# Copy the entrypoint script
COPY docker/protocol/entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

# Expose the port
EXPOSE 8081

# Set the entry point
ENTRYPOINT ["/app/entrypoint.sh"]
44 changes: 44 additions & 0 deletions docker/protocol/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Create .env file
cat << EOF > /app/.env
BOOTNODES=/ip4/35.223.224.220/udp/4001/quic-v1/p2p/16Uiu2HAmPxXXjR1XJEwckh6q1UStheMmGaGe8fyXdeRs3SejadSa,/ip4/34.121.111.128/udp/4001/quic-v1/p2p/16Uiu2HAmKULCxKgiQn1EcfKnq1Qam6psYLDTM99XsZFhr57wLadF
API_KEY=${API_KEY:-}
RPC_URL=${RPC_URL:-https://ethereum-sepolia.publicnode.com}
ENV=${ENV:-test}
FILE_PATH=${FILE_PATH:-.}
VALIDATOR=${VALIDATOR:-false}
PORT=${PORT:-8080}
# AI LLM
CLAUDE_API_KEY=${CLAUDE_API_KEY:-}
CLAUDE_API_URL=${CLAUDE_API_URL:-https://api.anthropic.com/v1/messages}
CLAUDE_API_VERSION=${CLAUDE_API_VERSION:-2023-06-01}
ELAB_URL=${ELAB_URL:-https://api.elevenlabs.io/v1/text-to-speech/ErXwobaYiN019PkySvjV/stream}
ELAB_KEY=${ELAB_KEY:-}
OPENAI_API_KEY=${OPENAI_API_KEY:-}
PROMPT=${PROMPT:-"You are a helpful assistant."}
# X
TWITTER_USER=${TWITTER_USER:-}
TWITTER_PASS=${TWITTER_PASS:-}
TWITTER_2FA_CODE=${TWITTER_2FA_CODE:-}
# Worker node config
TWITTER_SCRAPER=${TWITTER_SCRAPER:-true}
DISCORD_SCRAPER=${DISCORD_SCRAPER:-true}
WEB_SCRAPER=${WEB_SCRAPER:-true}
EOF

# Start the node
if [ "$STAKE_AMOUNT" != "" ]; then
echo "Staking $STAKE_AMOUNT MASA tokens..."
./masa-node --stake $STAKE_AMOUNT
echo "Staking completed. Restarting node..."
fi

./masa-node

# Keep the container running
tail -f /dev/null

0 comments on commit 09f483b

Please sign in to comment.