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

ci(Docker): set up subtensor, miner, and validator using Docker for CICD and testing #102

Merged
merged 87 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
e70949d
dockerize
5u6r054 Jun 18, 2024
70aad99
interactive responses to faucet run
5u6r054 Jun 18, 2024
0ec4194
successfully runs faucet
5u6r054 Jun 18, 2024
dd5c473
create miner and validator wallets, use faucet on each
5u6r054 Jun 18, 2024
0142c26
latest update to wallet script
5u6r054 Jun 19, 2024
8ac2ecf
owner faucet must run 4x to get sufficent tTAO (1000) to register the…
5u6r054 Jun 19, 2024
5bbdbf3
updates to naming
5u6r054 Jun 19, 2024
6bb30e3
more separation of concerns, separate machines for miner, validator, …
5u6r054 Jun 19, 2024
b6808c6
import that repeated do_faucet function for DRYness
5u6r054 Jun 19, 2024
2355c0d
give a new readme to the repo for ourselves.
5u6r054 Jun 19, 2024
410322d
use expect to interact when creating subnet
5u6r054 Jun 19, 2024
3303bb7
expect password to unlock wallet key for subnet registration
5u6r054 Jun 19, 2024
51c9614
check hyperparameters after subnet creation
5u6r054 Jun 19, 2024
1ba227b
don't login to dockerhub
5u6r054 Jun 19, 2024
d0e950e
refactor: move docker files to separate dirs
obasilakis Jun 20, 2024
1a39ffb
Merge remote-tracking branch 'origin/main' into dockerize
obasilakis Jun 20, 2024
2b08ac2
chore: make sure containers keep running
obasilakis Jun 24, 2024
2fdf363
chore: increase faucet timeout
obasilakis Jun 24, 2024
ef62817
feat: register validator WIP
obasilakis Jun 24, 2024
7c105db
creates subnet, registers validator
5u6r054 Jun 25, 2024
59fe8a0
now have subnet, miner, and validator all registering and running
5u6r054 Jun 25, 2024
489e602
standardize entrypoint script name and location
5u6r054 Jun 26, 2024
76745b2
cleanup old locations of scripts
5u6r054 Jun 26, 2024
cd2c3a4
add in new location for shared functions
5u6r054 Jun 26, 2024
ade3ef9
more rearranging files
5u6r054 Jun 26, 2024
5196f3f
update paths
5u6r054 Jun 26, 2024
4dfe434
updates to dependencies
5u6r054 Jun 26, 2024
c34acb3
fix function in miner entrypoint.sh that waits for validator
5u6r054 Jun 26, 2024
0851388
miner no need wait for subnet if wait for validator
5u6r054 Jun 26, 2024
b231471
make it try the docs endpoint
5u6r054 Jun 26, 2024
0493abf
fix healthcheck / wait for validator in miner
5u6r054 Jun 26, 2024
fa23824
make validator wait for miner
5u6r054 Jun 26, 2024
012b354
set remote oracle protocol url
5u6r054 Jun 26, 2024
c06a54e
feat: boost subnet on root subnet
obasilakis Jun 26, 2024
41fe456
upgrade faucet to 1000 instead of 100 per pull
5u6r054 Jun 26, 2024
013c817
make validator listen to external requests
5u6r054 Jun 26, 2024
d8575db
latest update runs all components
5u6r054 Jun 27, 2024
3ff3f11
set ORACLE_BASE_URL
5u6r054 Jun 27, 2024
668a89e
self hosted homerunner
5u6r054 Jun 27, 2024
8a3240f
wait longer before setting weights
5u6r054 Jun 27, 2024
201b8b0
typo fix
5u6r054 Jun 27, 2024
fc80ad1
wait 2250s (long enough for half the tempo number of blocks to go by)
5u6r054 Jun 27, 2024
d0f90bf
update validator start
5u6r054 Jun 27, 2024
bd67642
feat: set external IPs to docker IPs when starting miner and validator
obasilakis Jun 27, 2024
262aa2d
add axon ip flags to miner and validator at startup
5u6r054 Jun 27, 2024
aecd940
Merge remote-tracking branch 'origin/dockerize' into dockerize
obasilakis Jun 27, 2024
b02480c
Merge remote-tracking branch 'origin/dockerize' into dockerize
obasilakis Jun 27, 2024
d524649
add build contexts separate for each machine
5u6r054 Jun 27, 2024
e1cb457
give each machine its own separate build context
5u6r054 Jun 27, 2024
af9c79d
add publish / deploy workflow
5u6r054 Jun 27, 2024
6b7712a
norun
5u6r054 Jun 27, 2024
5577ec7
remove old self-host workflow
5u6r054 Jun 27, 2024
3c9b8cd
publish images
5u6r054 Jun 27, 2024
f447942
try self hosted again
5u6r054 Jun 27, 2024
111a025
try again with env named tag
5u6r054 Jun 27, 2024
1992e01
don't trigger on PRs
5u6r054 Jun 27, 2024
c741161
fix contexts for copying files
5u6r054 Jun 27, 2024
44fe9cb
fix arrangement of contexts and paths
5u6r054 Jun 27, 2024
5993cec
get the registry name right
5u6r054 Jun 27, 2024
d7aaac6
update validator and dockerfile
5u6r054 Jun 28, 2024
a50b31d
stake the validator
5u6r054 Jun 28, 2024
b5a6529
try waiting 1200s
5u6r054 Jun 28, 2024
73a741b
feat: stake validator
obasilakis Jun 28, 2024
18cfbd1
Merge remote-tracking branch 'origin/dockerize' into dockerize
obasilakis Jun 28, 2024
2a2ed86
fix: passing correct ORACLE_BASE_URL to miner
obasilakis Jun 28, 2024
9c50eaa
fix: stake validator before starting it
obasilakis Jun 28, 2024
8715157
fix: log
obasilakis Jun 28, 2024
b13d37d
feat: restart validator to get rid of broken pipe error
obasilakis Jun 28, 2024
9a5beb5
fix paths
5u6r054 Jun 28, 2024
f9560ac
build images in separate stages
5u6r054 Jun 28, 2024
59067de
update docker-compose to use github action produced images
5u6r054 Jul 1, 2024
2a78cf2
sleep before restart
5u6r054 Jul 1, 2024
84e7eab
don't require an env var for determining branch name/ env
5u6r054 Jul 1, 2024
f251f87
path filters for granular image rebuilds
5u6r054 Jul 1, 2024
5ec5b33
update Makefile so 'make up
5u6r054 Jul 1, 2024
95d347b
update restart to give it time.
5u6r054 Jul 1, 2024
09f483b
add protocol node
5u6r054 Jul 1, 2024
875d989
make github action not skip builds
5u6r054 Jul 1, 2024
668e19c
make github action not skip builds
5u6r054 Jul 1, 2024
adc63d6
rebuild
5u6r054 Jul 1, 2024
58f9ed6
no a
5u6r054 Jul 1, 2024
bf551ad
make miner use local protocol node
5u6r054 Jul 2, 2024
5080347
don't mark with a commit, use an artifact
5u6r054 Jul 2, 2024
d1bb3c7
auth and login
5u6r054 Jul 2, 2024
486d064
auth and login
5u6r054 Jul 2, 2024
818afec
token
5u6r054 Jul 2, 2024
dbc17fa
update validator restart
5u6r054 Jul 2, 2024
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
98 changes: 98 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Docker Build and Publish

on:
push:
branches: [ "dev", "test", "main", "dockerize" ]
paths:
- 'docker/**'
- '.github/workflows/docker-publish.yml'
- '**/*.py'

jobs:
check-and-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
image: [subtensor, subnet, miner, validator, protocol]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download last successful build info
uses: actions/download-artifact@v3
with:
name: last-successful-build
path: .
continue-on-error: true

- name: Check for changes
id: check_changes
run: |
if [ -f last_successful_build.txt ]; then
LAST_SUCCESSFUL_SHA=$(cat last_successful_build.txt)
else
echo "No previous successful build found. Building all images."
echo "changed=true" >> $GITHUB_OUTPUT
exit 0
fi
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

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
if: steps.check_changes.outputs.changed == 'true'
run: |
if [ "${{ matrix.image }}" == "subtensor" ]; then
CONTEXT="./docker/subtensor"
else
CONTEXT="."
fi
docker build -t ghcr.io/masa-finance/masa-bittensor/${{ matrix.image }}:${{ github.ref_name }} -f docker/${{ matrix.image }}/Dockerfile $CONTEXT
docker push ghcr.io/masa-finance/masa-bittensor/${{ matrix.image }}:${{ github.ref_name }}

mark-success:
needs: check-and-build
runs-on: ubuntu-latest
steps:
- name: Create success marker
run: echo ${{ github.sha }} > last_successful_build.txt
- name: Upload success marker
uses: actions/upload-artifact@v3
with:
name: last-successful-build
path: last_successful_build.txt
retention-days: 1

display-tags:
needs: check-and-build
runs-on: ubuntu-latest
steps:
- name: Display image tags
run: |
echo "The following images may have been built and pushed:"
echo "ghcr.io/masa-finance/masa-bittensor/subtensor:${{ github.ref_name }}"
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 }}"
36 changes: 35 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
DOCKER_COMPOSE := BRANCH_NAME=$(BRANCH_NAME) docker compose

LOCAL_ENDPOINT = ws://127.0.0.1:9945
LOCALNET = chain_endpoint $(LOCAL_ENDPOINT)
Expand Down Expand Up @@ -120,4 +122,36 @@ run-localnet:

## Hyperparameters
hyperparameters:
btcli subnets hyperparameters --subtensor.$(SUBTENSOR_ENVIRONMENT) --netuid $(NETUID)
btcli subnets hyperparameters --subtensor.$(SUBTENSOR_ENVIRONMENT) --netuid $(NETUID)

########################################################################
##### DOCKER COMPOSE COMMANDS #####
########################################################################

.PHONY: up down build logs

pull:
$(DOCKER_COMPOSE) pull

up:
$(DOCKER_COMPOSE) pull
$(DOCKER_COMPOSE) up -d

down:
$(DOCKER_COMPOSE) down

build:
$(DOCKER_COMPOSE) build

logs:
$(DOCKER_COMPOSE) logs -f

# You can keep your existing docker commands or replace them with these:
docker-build:
$(DOCKER_COMPOSE) build

docker-up:
$(DOCKER_COMPOSE) up -d

docker-down:
$(DOCKER_COMPOSE) down
Loading
Loading