Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve Docker setup and multi-platform publishing #345

Draft
wants to merge 109 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
b3a6c72
docker setup
5u6r054 Jan 28, 2025
3f9690b
push base image
5u6r054 Jan 28, 2025
94adc70
refactor(docker): simplify configuration to use docker-compose direct…
5u6r054 Jan 28, 2025
18bf8e3
refactor(docker): improve multi-stage build - Keep build dependencies…
5u6r054 Jan 28, 2025
9fca5e5
fix(docker): combine Rust and pip install steps to ensure Rust is in …
5u6r054 Jan 28, 2025
7306b49
refactor: move docker files to root directory for simpler imports and…
5u6r054 Jan 28, 2025
91f8639
rename entrypoint.py
5u6r054 Jan 28, 2025
163799e
feat(docker): streamline compose setup for local development - Simpli…
5u6r054 Jan 28, 2025
b5cc3da
refactor: improve wallet handling and orchestrator implementation - U…
5u6r054 Jan 28, 2025
60f4d45
chore: add cursor IDE config to gitignore
5u6r054 Jan 28, 2025
62d1041
feat(validator): implement auto-registration and startup - Add wallet…
5u6r054 Jan 29, 2025
c7991f4
chore(docker): improve container configuration - Update Docker and co…
5u6r054 Jan 29, 2025
053b725
chore(deps): allow newer versions while maintaining compatibility - A…
5u6r054 Jan 29, 2025
b112906
adjustments to store states of validators on mounted vol
5u6r054 Jan 29, 2025
d14e78d
fix: proper port allocation for multiple validators/miners - Use port…
5u6r054 Jan 29, 2025
41a2145
feat: enhance validator and miner orchestration - Add dynamic port al…
5u6r054 Jan 29, 2025
dc53929
refactor: modularize container startup code into focused classes
5u6r054 Jan 29, 2025
7e09430
ci: add feature-docker-compose branch to image build triggers
5u6r054 Jan 29, 2025
29ac389
refactor: optimize Dockerfile layers with explicit dependency install…
5u6r054 Jan 29, 2025
5ceac68
remove cruft
5u6r054 Jan 29, 2025
6333d55
refactor: optimize for development with volume mounts and runtime pac…
5u6r054 Jan 29, 2025
42b7f76
feat(docker): Improve Docker Compose setup for scalable deployment
5u6r054 Jan 30, 2025
813095b
run builds for docker hub
5u6r054 Jan 30, 2025
7282bd4
fix up docker hub flow
5u6r054 Jan 30, 2025
7cd7d40
refactor: improve docker setup and healthchecks
5u6r054 Jan 30, 2025
ead07da
set up workflow to complete
5u6r054 Jan 30, 2025
a5dd2f7
trigger rebuild
5u6r054 Jan 30, 2025
a179a7a
fix: add explicit scipy dependency required by scorer module
5u6r054 Jan 30, 2025
6f7433e
build: optimize docker build for arm64 architectures
5u6r054 Jan 30, 2025
73fe989
build: optimize docker image size and build time
5u6r054 Jan 30, 2025
4050b17
feat: improve docker publish workflow with latest tag and better rele…
5u6r054 Jan 30, 2025
f11badb
feat: improve image handling to use published images by default with …
5u6r054 Jan 30, 2025
76c283e
feat: add comprehensive start script with status monitoring
5u6r054 Jan 30, 2025
e28de83
docs: add Docker Hub overview and documentation
5u6r054 Jan 30, 2025
eb720d4
feat: improve startup feedback and add Docker Hub sync
5u6r054 Jan 30, 2025
0264c09
startup script
5u6r054 Jan 30, 2025
ad60f6a
fix: improve startup reliability and dependency management - Fix depe…
5u6r054 Jan 30, 2025
d6e4582
fix slow build due to bittensor
5u6r054 Jan 30, 2025
a4eba1c
Fix deps back
5u6r054 Jan 30, 2025
630ca07
fix slow build
5u6r054 Jan 30, 2025
37ae021
update to run with new validator key
5u6r054 Jan 30, 2025
5ff9b68
choose wisely with bittensor parts to include
5u6r054 Jan 30, 2025
596a9b7
build: optimize bittensor dependencies with flexible versions and pre…
5u6r054 Jan 30, 2025
aa77f94
build: use exact working versions of bittensor packages
5u6r054 Jan 30, 2025
6831fb7
build: allow compiling bittensor packages for ARM support
5u6r054 Jan 30, 2025
ab0c983
build: optimize bittensor installation by using --no-deps to prevent …
5u6r054 Jan 30, 2025
ba325be
build: add bittensor core dependencies and remove deprecated compose …
5u6r054 Jan 30, 2025
711f292
build: improve service startup reliability and error detection
5u6r054 Jan 30, 2025
f19f25b
build: improve dependency handling and container monitoring - Add nes…
5u6r054 Jan 30, 2025
d3e8a32
build: add nest-asyncio dependency and improve container restart dete…
5u6r054 Jan 30, 2025
722f6b7
build: add aiohttp dependency and prevent container restarts
5u6r054 Jan 30, 2025
8d33808
fix: add scalecodec dependency and improve deployment error handling
5u6r054 Jan 30, 2025
b6ce8fd
fix: add bittensor_wallet dependency
5u6r054 Jan 30, 2025
c2a87da
fix: use pre-built wheel for bittensor_wallet on ARM64
5u6r054 Jan 30, 2025
82313b3
fix: align dependency versions with bittensor 8.5.2 requirements
5u6r054 Jan 30, 2025
c667127
fix: add substrate-interface dependency
5u6r054 Jan 30, 2025
7a6e7fd
fix: add complete set of bittensor dependencies
5u6r054 Jan 30, 2025
b8d1f3f
fix: add ansible dependency for bittensor_wallet key encryption
5u6r054 Jan 30, 2025
b3b8de0
fix: add ansible-vault package required by bittensor_wallet keyfile e…
5u6r054 Jan 30, 2025
83db3a3
fix: allow bittensor_wallet to install dependencies for Keypair funct…
5u6r054 Jan 30, 2025
ef688ca
fix: remove --only-binary flag from bittensor_wallet installation
5u6r054 Jan 30, 2025
02c7286
fix: update bittensor_wallet to version 3.0.0
5u6r054 Jan 31, 2025
713eaad
fix: downgrade bittensor_wallet to 2.1.3 for compatibility with bitte…
5u6r054 Jan 31, 2025
e23444c
fix: pin bittensor to exact version 8.2.0 for compatibility with wall…
5u6r054 Jan 31, 2025
e40c2d6
perf: optimize Dockerfile to reduce build time
5u6r054 Jan 31, 2025
91551eb
refactor: split pip installations into logical groups for better debu…
5u6r054 Jan 31, 2025
70a7970
fix: optimize bittensor installation and add required system dependen…
5u6r054 Jan 31, 2025
76b5b7e
fix: improve ARM64 build support and prevent segfaults during compila…
5u6r054 Jan 31, 2025
bd5bd33
fix: explicitly specify dependencies and remove process substitution
5u6r054 Jan 31, 2025
437f0a6
refactor: use multi-stage build for Rust components
5u6r054 Jan 31, 2025
ce6b288
fix: improve ARM64 support in Dockerfile
5u6r054 Jan 31, 2025
f1064c0
refactor: optimize Docker build layers and compilation
5u6r054 Jan 31, 2025
99cb00a
feat: upgrade to bittensor-wallet 3.0.0
5u6r054 Jan 31, 2025
bed6577
refactor: use pre-built wheels and optimize installation order
5u6r054 Jan 31, 2025
669d425
refactor: remove unused builder stage and pin bittensor-wallet version
5u6r054 Jan 31, 2025
b28a0d8
feat: add Rust toolchain for bittensor-commit-reveal dependency
5u6r054 Jan 31, 2025
e4b8b10
refactor: use pre-built wheels consistently and remove Rust toolchain
5u6r054 Jan 31, 2025
35675df
fix: allow source installation for ansible-vault
5u6r054 Jan 31, 2025
8346dd6
fix: resolve masa-ai dependency conflict
5u6r054 Jan 31, 2025
12c2e19
fix: allow source installation for masa-ai and its dependencies
5u6r054 Jan 31, 2025
d3ea5a4
fix: allow source installation for bittensor-commit-reveal
5u6r054 Jan 31, 2025
a9249dd
fix: add Rust installation for bittensor-commit-reveal
5u6r054 Jan 31, 2025
e41954f
fix: reorder bittensor package installations
5u6r054 Jan 31, 2025
0389582
fix: allow source installation for bittensor-wallet
5u6r054 Jan 31, 2025
c84af0e
feat: use latest versions of bittensor and bittensor-wallet
5u6r054 Jan 31, 2025
48c667b
fix: try older version of bittensor-wallet with pre-built wheels
5u6r054 Jan 31, 2025
26b84f9
refactor: optimize layers and remove duplicate dependencies
5u6r054 Jan 31, 2025
d78fbe9
fix: reorder bittensor package installation and allow source builds
5u6r054 Jan 31, 2025
057dace
feat: use official bittensor image as base
5u6r054 Jan 31, 2025
1f0d669
fix: use bittensor/bittensor:latest as base image
5u6r054 Jan 31, 2025
8469f28
fix: remove platform specification and simplify dependencies
5u6r054 Jan 31, 2025
4c711b7
fix: use Python 3.12 base image and target AMD64 only
5u6r054 Jan 31, 2025
6b29892
fix: use official bittensor image for AMD64 only
5u6r054 Jan 31, 2025
ffca8c2
feat: use Python 3.12 venv for masa-ai while keeping bittensor in sys…
5u6r054 Jan 31, 2025
b460f5c
fix: install all packages in Python 3.12 virtualenv
5u6r054 Jan 31, 2025
9c4e835
fix: specify aiohttp version for Python 3.12 compatibility
5u6r054 Jan 31, 2025
c76d2d1
fix: separate Python environments - bittensor in system 3.8, masa-ai …
5u6r054 Jan 31, 2025
9c5fa96
fix: simplify to use base image's Python 3.8 for both bittensor and m…
5u6r054 Jan 31, 2025
bc71729
refactor: use standard Python base image and explicit dependencies
5u6r054 Jan 31, 2025
8c12177
feat: align Dockerfile with project requirements - Python 3.12 and ex…
5u6r054 Jan 31, 2025
08b3da0
feat: integrate masa-protocol and standardize docker-compose with con…
5u6r054 Jan 31, 2025
3d08225
feat: add comprehensive .env.example with documented configuration op…
5u6r054 Jan 31, 2025
ad8d259
refactor: remove build contexts and use published Docker Hub images only
5u6r054 Jan 31, 2025
aa0c948
refactor: simplify docker-compose to support scalable miners/validato…
5u6r054 Jan 31, 2025
e24dd17
refactor: remove version field and NETUID from compose file
5u6r054 Jan 31, 2025
a2a49f7
fix: add COPY commands for startup and masa directories, remove hardc…
5u6r054 Jan 31, 2025
349a554
refactor: mount code directories instead of baking into image
5u6r054 Jan 31, 2025
2fe33fc
refactor: remove profiles, let swarm handle zero replicas naturally
5u6r054 Jan 31, 2025
8a9746a
fix: update monitoring to handle validator and miner services separately
5u6r054 Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# Docker image versions
TAG=latest # Version tag for masa-bittensor images
PROTOCOL_VERSION=latest # Version of masa-protocol to use

# Network configuration
NETWORK=test # Network to connect to (test/finney)
NODE_ENV=production # Node environment for protocol service

# Port configuration
PROTOCOL_PORT=8081 # Masa Protocol HTTP port
P2P_PORT=4001 # Masa Protocol P2P port
VALIDATOR_PORT=8092 # Validator service port
VALIDATOR_METRICS_PORT=8000 # Validator metrics port
MINER_PORT=8093 # Miner service port
MINER_METRICS_PORT=8001 # Miner metrics port

# Bittensor wallet configuration
COLDKEY_PASSWORD=your_coldkey_password # Password for coldkey
HOTKEY_PASSWORD=your_hotkey_password # Password for hotkey

# Optional: Advanced configuration
# COLDKEY_MNEMONIC= # Mnemonic for coldkey regeneration (optional)
# NETUID=42 # Subnet ID (defaults to 42 for masa subnet)
# PROTOCOL_URL=http://protocol:8081 # Internal URL for protocol service

VALIDATOR_API_HOST=127.0.0.1
VALIDATOR_API_PORT=8000
ORACLE_BASE_URL=http://127.0.0.1:8080/api/v1
18 changes: 18 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Number of miners to run (1-255)
MINER_COUNT=1

# Number of validators to run (0-255)
VALIDATOR_COUNT=1

# Your coldkey mnemonic (KEEP THIS SECURE!)
# Example format: "word1 word2 word3 word4 ... word12"
COLDKEY_MNEMONIC=""

# Network to connect to (test/finney)
NETWORK=test

# Logging level (DEBUG/INFO/WARNING/ERROR)
LOGGING_DEBUG=INFO

# Optional: Custom docker image (leave empty to use latest from Docker Hub)
# DOCKER_IMAGE=masaengineering/masa-bittensor:latest
26 changes: 26 additions & 0 deletions .github/workflows/docker-hub-description.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Update Docker Hub Description

on:
push:
branches:
- feature-docker-compose
- main
paths:
- 'DOCKER.md'
- '.github/workflows/docker-hub-description.yml'

jobs:
docker-hub-description:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: masaengineering/masa-bittensor
short-description: "MASA Bittensor miners and validators in Docker"
readme-filepath: ./DOCKER.md
139 changes: 66 additions & 73 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,90 +1,83 @@
name: Docker Build and Publish
name: 'Build and Publish Images to Docker Hub'

on:
push:
branches: [ "dockerize" ]
release:
types: [published]
branches:
- feature-docker-compose
tags:
- 'v*' # Only trigger on version tags

jobs:
check-and-build:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
image: [subtensor, subnet, miner, validator, protocol]
timeout-minutes: 240 # Increased timeout for ARM64 builds
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
fetch-depth: 0
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Cache last successful build info
uses: actions/cache@v3
# Tag generation with latest and release handling
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
path: last_successful_build_${{ matrix.image }}.txt
key: ${{ runner.os }}-last-build-${{ matrix.image }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-last-build-${{ matrix.image }}-
images: masaengineering/masa-bittensor
tags: |
# Always push latest
type=raw,value=latest
# Branch builds with timestamp
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmmss'}}
# SHA with timestamp
type=sha,format=short,prefix=sha-,suffix=-{{date 'YYYYMMDDHHmmss'}}
# Version tags (v1.2.3 -> 1.2.3, latest)
type=semver,pattern={{version}},value=${{ github.ref_name }}
type=semver,pattern={{major}}.{{minor}},value=${{ github.ref_name }}
type=semver,pattern={{major}},value=${{ github.ref_name }}

- name: Check for changes
id: check_changes
# Debug step to see what tags will be used
- name: Debug Docker Tags
run: |
if [ -f last_successful_build_${{ matrix.image }}.txt ]; then
LAST_SUCCESSFUL_SHA=$(cat last_successful_build_${{ matrix.image }}.txt)
if [ "${{ matrix.image }}" == "subtensor" ]; then
CHANGED=$(git diff --name-only $LAST_SUCCESSFUL_SHA HEAD -- docker/subtensor)
else
CHANGED=$(git diff --name-only $LAST_SUCCESSFUL_SHA HEAD -- docker/${{ matrix.image }} **/*.py)
fi

if [ -n "$CHANGED" ]; then
echo "Changes detected for ${{ matrix.image }}. Building image."
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "No changes detected for ${{ matrix.image }}. Skipping build."
echo "changed=false" >> $GITHUB_OUTPUT
fi
else
echo "No previous successful build found for ${{ matrix.image }}. Building image."
echo "changed=true" >> $GITHUB_OUTPUT
fi
echo "Tags to be used:"
echo "${{ steps.meta.outputs.tags }}"
echo "Is this a release? ${{ startsWith(github.ref, 'refs/tags/v') }}"

- name: Log in to GitHub Container Registry
if: steps.check_changes.outputs.changed == 'true' || github.event_name == 'release'
uses: docker/login-action@v2
- name: Build and push
uses: docker/build-push-action@v5
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push image
if: steps.check_changes.outputs.changed == 'true' || github.event_name == 'release'
# Verify the push was successful
- name: Verify Push
run: |
if [ "${{ matrix.image }}" == "subtensor" ]; then
CONTEXT="./docker/subtensor"
else
CONTEXT="."
fi
TAG=${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }}
docker build -t ghcr.io/masa-finance/masa-bittensor/${{ matrix.image }}:$TAG -f docker/${{ matrix.image }}/Dockerfile $CONTEXT
docker push ghcr.io/masa-finance/masa-bittensor/${{ matrix.image }}:$TAG

- name: Mark successful build
if: steps.check_changes.outputs.changed == 'true' || github.event_name == 'release'
run: echo ${{ github.sha }} > last_successful_build_${{ matrix.image }}.txt
echo "Verifying pushed images..."
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' '); do
echo "Checking tag: $tag"
docker pull $tag
done

display-tags:
needs: check-and-build
runs-on: ubuntu-latest
steps:
- name: Display image tags
# Announce the release in the logs
- name: Announce Release
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG=${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }}
echo "The following images may have been built and pushed:"
echo "ghcr.io/masa-finance/masa-bittensor/subtensor:$TAG"
echo "ghcr.io/masa-finance/masa-bittensor/subnet:$TAG"
echo "ghcr.io/masa-finance/masa-bittensor/miner:$TAG"
echo "ghcr.io/masa-finance/masa-bittensor/validator:$TAG"
echo "ghcr.io/masa-finance/masa-bittensor/protocol:$TAG"
echo "🎉 Released version ${GITHUB_REF#refs/tags/v}"
echo "Published tags:"
echo "${{ steps.meta.outputs.tags }}"
Loading
Loading