Skip to content

Commit 6e36f82

Browse files
Tedbeestedbee
and
tedbee
authoredFeb 17, 2025··
feat: docker revamp (#119)
* feat: docker revamp * chore: remove /app mounts * chore: cleanups * chore: add watchtower to miner * chore: added command for watchtower * chore: updated readme, updated makefile * chore: Updated README and .env example * chore: Remove duplicate env file * chore: remove wandb from env and README * chore: updated env DATASET_SERVICE_BASE_URL to VALIDATOR_API_BASE_URL --------- Co-authored-by: tedbee <[email protected]>
1 parent 53082e7 commit 6e36f82

12 files changed

+657
-654
lines changed
 

‎.env.example

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# ---------------------------------------------------------------------------- #
2+
# BITTENSOR ENV VARS #
3+
# ---------------------------------------------------------------------------- #
4+
5+
BITTENSOR_DIR=$HOME/.bittensor
6+
WALLET_COLDKEY=
7+
WALLET_HOTKEY=
8+
9+
NETUID=52
10+
SUBTENSOR_NETWORK=finney
11+
SUBTENSOR_ENDPOINT=wss://entrypoint-finney.opentensor.ai:443
12+
13+
# ---------------------------------------------------------------------------- #
14+
# MINER ENV VARS #
15+
# ---------------------------------------------------------------------------- #
16+
17+
DOJO_API_BASE_URL=https://dojo-api.tensorplex.ai
18+
DOJO_API_KEY=
19+
AXON_PORT=8091
20+
# VALIDATOR_MIN_STAKE=20000
21+
22+
# ---------------------------------------------------------------------------- #
23+
# VALIDATOR ENV VARS #
24+
# ---------------------------------------------------------------------------- #
25+
26+
OPENROUTER_API_KEY=
27+
SYNTHETIC_API_URL=http://synthetic-api:5003
28+
29+
LANGFUSE_SECRET_KEY=
30+
LANGFUSE_PUBLIC_KEY=
31+
LANGFUSE_HOST="https://us.cloud.langfuse.com" # 🇺🇸 US region
32+
VALIDATOR_API_BASE_URL=https://dojo-validator-api.tensorplex.ai
33+
34+
DOJO_LOKI_URL=https://dojo-logs.tensorplex.ai
35+
# hotkey for loki external label
36+
VALIDATOR_HOTKEY=
37+
38+
39+
# ---------------------------------------------------------------------------- #
40+
# WORKER PLATFORM / VALIDATOR SHARED ENV VARS #
41+
# ---------------------------------------------------------------------------- #
42+
43+
DB_HOST=postgres:5432
44+
DB_NAME=db
45+
DB_USERNAME=
46+
DB_PASSWORD=
47+
DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}
48+
49+
REDIS_HOST=redis
50+
REDIS_PORT=6379
51+
52+
53+
# ---------------------------------------------------------------------------- #
54+
# WORKER PLATFORM ENV VARS #
55+
# ---------------------------------------------------------------------------- #
56+
57+
# Substrate Sidecar
58+
SAS_SUBSTRATE_URL=${SUBTENSOR_ENDPOINT}
59+
SAS_EXPRESS_PORT=8081
60+
61+
# Dojo UI
62+
NEXT_PUBLIC_BACKEND_URL=http://localhost:3000
63+
64+
# Dojo Worker API
65+
REDIS_USERNAME=
66+
REDIS_PASSWORD=
67+
RUNTIME_ENV=local
68+
SERVER_PORT=8080
69+
SUBNET_UID=98
70+
CORS_ALLOWED_ORIGINS=http://localhost*,http://worker-ui*,http://dojo-cli*
71+
SUBSTRATE_API_URL=sidecar:8081
72+
TOKEN_EXPIRY=24
73+
VALIDATOR_MIN_STAKE=20000
74+
75+
AWS_ACCESS_KEY_ID=
76+
AWS_SECRET_ACCESS_KEY=
77+
AWS_S3_BUCKET_NAME=
78+
S3_PUBLIC_URL=
79+
80+
# Random JWT Secret
81+
JWT_SECRET=
82+
# e.g. infura, alchemy API url for ethereum
83+
ETHEREUM_NODE=https://ethereum.publicnode.com
84+
85+
# ---------------------------------------------------------------------------- #
86+
# MIGRATION ENV VARS #
87+
# ---------------------------------------------------------------------------- #
88+
89+
MIGRATION_BATCH_SIZE=5000
90+
MIGRATION_MAX_CONCURRENT_TASKS=15
91+
MIGRATION_LOG_DIR=logs/migration/
92+
MINER_TX_TIMEOUT=10
93+
VALIDATOR_TX_TIMEOUT=10
94+
95+
# ---------------------------------------------------------------------------- #
96+
# OTHER ENV VARS #
97+
# ---------------------------------------------------------------------------- #
98+
99+
SIMULATION=false
100+
FAST_MODE=false
101+
102+
103+

‎.env.miner.example

-51
This file was deleted.

‎.env.validator.example

-47
This file was deleted.

‎Makefile

+33-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PRECOMMIT_VERSION="3.7.1"
22
UNAME := $(shell uname)
3-
.PHONY: hooks install install-dev install-test btcli validator-pull miner-pull validator-down miner-down miner-decentralised miner-centralised validator validator-up-deps miner-worker-api dojo-cli miner-decentralised-logs miner-centralised-logs validator-logs subtensor-mainnet subtensor-testnet
3+
.PHONY: hooks install install-dev install-test btcli validator-pull miner-pull miner-decentralised miner-centralised validator validator-up-deps miner-worker-api dojo-cli miner-decentralised-logs miner-centralised-logs validator-logs
44

55
hooks:
66
@echo "Grabbing pre-commit version ${PRECOMMIT_VERSION} and installing pre-commit hooks"
@@ -41,38 +41,35 @@ btcli:
4141
docker compose -f docker-compose.shared.yaml run --rm btcli
4242

4343
validator-pull:
44-
docker compose --env-file .env.validator -f docker-compose.validator.yaml pull --include-deps
44+
docker compose -f docker-compose.validator.yaml pull --include-deps
4545

4646
miner-pull:
47-
docker compose --env-file .env.miner -f docker-compose.miner.yaml pull --include-deps
47+
docker compose -f docker-compose.miner.yaml pull --include-deps
4848

4949
validator-down:
50-
docker compose --env-file .env.validator -f docker-compose.validator.yaml down
50+
docker compose -f docker-compose.validator.yaml down
5151

5252
miner-down:
53-
docker compose --env-file .env.miner -f docker-compose.miner.yaml down
53+
docker compose -f docker-compose.miner.yaml down
5454

5555
# ---------------------------------------------------------------------------- #
5656
# CORE SERVICES #
5757
# ---------------------------------------------------------------------------- #
5858

59-
miner-decentralised:
60-
docker compose --env-file .env.miner -f docker-compose.miner.yaml up -d --build miner-decentralised
61-
62-
miner-centralised:
63-
docker compose --env-file .env.miner -f docker-compose.miner.yaml up --build -d miner-centralised
59+
miner:
60+
docker compose -f docker-compose.miner.yaml up -d miner
6461

6562
validator:
66-
docker compose --env-file .env.validator -f docker-compose.validator.yaml up --build -d validator
63+
docker compose -f docker-compose.validator.yaml up -d validator
6764

6865
validator-up-deps:
69-
docker compose --env-file .env.validator -f docker-compose.validator.yaml up -d --build synthetic-api postgres-vali prisma-setup-vali
66+
docker compose -f docker-compose.validator.yaml up -d --build synthetic-api postgres-vali prisma-setup-vali
7067

71-
miner-worker-api:
72-
docker compose --env-file .env.miner -f docker-compose.miner.yaml up -d worker-api
68+
dojo-platform:
69+
docker compose -f docker-compose.platform.yaml up -d
7370

7471
dojo-cli:
75-
docker compose --env-file .env.miner -f docker-compose.miner.yaml run --rm dojo-cli
72+
docker compose -f docker-compose.miner.yaml run --rm dojo-cli
7673

7774
extract-dataset:
7875
docker compose -f docker-compose.validator.yaml run --rm --remove-orphans extract-dataset
@@ -81,20 +78,20 @@ fill-score-column:
8178
docker compose -f docker-compose.validator.yaml run --rm --remove-orphans fill-score-column
8279

8380
migration:
84-
docker compose --env-file .env.validator -f docker-compose.validator.yaml run --rm migration
81+
docker compose -f docker-compose.validator.yaml run --rm migration
8582

8683
# ---------------------------------------------------------------------------- #
8784
# CORE SERVICE LOGGING #
8885
# ---------------------------------------------------------------------------- #
8986

9087
miner-decentralised-logs:
91-
docker compose --env-file .env.miner -f docker-compose.miner.yaml logs -f miner-decentralised
88+
docker compose -f docker-compose.miner.yaml logs -f miner-decentralised
9289

9390
miner-centralised-logs:
94-
docker compose --env-file .env.miner -f docker-compose.miner.yaml logs -f miner-centralised
91+
docker compose -f docker-compose.miner.yaml logs -f miner-centralised
9592

9693
validator-logs:
97-
docker compose --env-file .env.validator -f docker-compose.validator.yaml logs -f validator
94+
docker compose -f docker-compose.validator.yaml logs -f validator
9895

9996
# ---------------------------------------------------------------------------- #
10097
# LOCAL SUBTENSOR #
@@ -105,3 +102,20 @@ subtensor-mainnet:
105102

106103
subtensor-testnet:
107104
docker compose -f docker-compose.subtensor.yaml up -d testnet-lite
105+
106+
# ---------------------------------------------------------------------------- #
107+
# WORKER PLATFORM #
108+
# ---------------------------------------------------------------------------- #
109+
110+
worker-platform:
111+
docker compose -f docker-compose.platform.yaml up -d
112+
113+
# ---------------------------------------------------------------------------- #
114+
# OTHERS #
115+
# ---------------------------------------------------------------------------- #
116+
117+
watchtower:
118+
docker compose -f docker-compose.shared.yaml up -d watchtower
119+
120+
watchtower-down:
121+
docker compose -f docker-compose.shared.yaml down watchtower

‎README-miner.md

+169
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# Mining
2+
There are two options in setting up a miner for Dojo (centralised method and decentralised method)
3+
4+
Before starting, create a .env file by making a copy of .env.example
5+
6+
```bash
7+
cp .env.example .env
8+
```
9+
10+
### Option 1: Centralised Method
11+
Complete the .env file by changing / uncommenting the required variables
12+
13+
| Variable | Description | Default Value | Remarks |
14+
|---------------------|-------------------------------------------------------------------|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
15+
| BITTENSOR_DIR | Bittensor directory | $HOME/.bittensor | |
16+
| WALLET_COLDKEY | Bittensor coldkey name | - | |
17+
| WALLET_HOTKEY | Bittensor hotkey name | - | |
18+
| NETUID | Subnet ID | 52 | 52 for mainnet <br>98 for testnet |
19+
| SUBTENSOR_NETWORK | Network name | mainnet | finney (mainnet) <br>test (testnet) <br>local (local subtensor) |
20+
| SUBTENSOR_ENDPOINT | WebSocket endpoint for network connection | <wss://entrypoint-finney.opentensor.ai:443> | <wss://test.finney.opentensor.ai:443> for testnet <br><ws://mainnet-lite:9944> for local subtensor <br><ws://testnet-lite:9944> for local testnet subtensor |
21+
| DOJO_API_BASE_URL | Base URL for Dojo API | <https://dojo-api.tensorplex.ai> | Dojo Worker API URL |
22+
| DOJO_API_KEY | Authentication key for Dojo API | - | Dojo API key (Generate it in the next step) |
23+
| AXON_PORT | Port for Axon server | 8091 | |
24+
| VALIDATOR_MIN_STAKE | Optional minimum stake requirement | 20000 | It is recommended to set value to 0 for testnet |
25+
| TASK_MAX_RESULTS | The number of workers that may submit responses for a single task | 4 | |
26+
27+
Run Dojo CLI to retrieve API Key and Subscription Key. See [Dojo CLI](#dojo-cli) for usage. Note down the API key, subscription key and append the API key to your .env file.
28+
29+
> You can use tab completions to see a list of commands
30+
31+
```bash
32+
make dojo-cli
33+
34+
# Authenticate and generate keys
35+
authenticate
36+
api_key generate
37+
subscription_key generate
38+
39+
# List all keys
40+
api_key list
41+
subscription_key list
42+
```
43+
44+
Start the miner by running the following commands
45+
46+
```bash
47+
make miner
48+
```
49+
50+
### Option 2: Decentralised Method
51+
52+
Complete the .env file by changing / uncommenting the required variables
53+
54+
| Variable | Description | Default Value | Remarks |
55+
|-------------------------|-------------------------------|--------------------------------------------------------|-----------------------------------------|
56+
| SAS_SUBSTRATE_URL | Substrate URL | Same as SUBTENSOR_ENDPOINT | Must match network configuration |
57+
| SAS_EXPRESS_PORT | Sidecar Express server port | 8081 | Internal service port |
58+
| SUBSTRATE_API_URL | Substrate API URL | sidecar:8081 | Internal service endpoint |
59+
| NEXT_PUBLIC_BACKEND_URL | Backend URL for Dojo UI | <http://localhost:3000> | Must be accessible from UI |
60+
| SERVER_PORT | Worker API server port | 8080 | Must not conflict with other services |
61+
| RUNTIME_ENV | Runtime environment | aws | Options: local, development, production |
62+
| CORS_ALLOWED_ORIGINS | Allowed CORS origins | <http://localhost*,http://worker-ui*,http://dojo-cli>* | Comma-separated list |
63+
| TOKEN_EXPIRY | JWT token expiration in hours | 24 | Adjust if needed |
64+
| JWT_SECRET | Secret key for JWT tokens | - | Use a strong random string |
65+
| AWS_ACCESS_KEY_ID | AWS access key ID | - | Optional |
66+
| AWS_SECRET_ACCESS_KEY | AWS secret access key | - | Optional |
67+
| AWS_S3_BUCKET_NAME | S3 bucket name | - | Optional |
68+
| S3_PUBLIC_URL | Public URL for S3 bucket | - | Optional |
69+
| REDIS_HOST | Redis host | redis | Container name or IP |
70+
| REDIS_PORT | Redis port | 6379 | Default Redis port |
71+
| REDIS_USERNAME | Redis username | - | (Optional) For Redis ACL |
72+
| REDIS_PASSWORD | Redis password | - | (Optional) For Redis authentication |
73+
| DB_HOST | Database host address | postgres:5432 | Format: hostname:port |
74+
| DB_NAME | Database name | db | Database Name |
75+
| DB_USERNAME | Database username | - | Database Username |
76+
| DB_PASSWORD | Database password | - | Database Password |
77+
| VALIDATOR_MIN_STAKE | Validator Minimum Stake | 20000 | Minimum stake required from validators |
78+
| ETHEREUM_NODE | Ethereum Node endpoint | <https://ethereum.publicnode.com> | Ethereum endpoint |
79+
Start the dojo platform which Dojo CLI will interact with later.
80+
81+
```bash
82+
make dojo-platform
83+
```
84+
85+
Refer to [option 1](#option-1-centralised-method) to continue setting up the miner.
86+
87+
### Setup Subscription Key for Labellers on UI to connect to Dojo Subnet for scoring
88+
89+
Note: URLs are different for testnet and mainnet. Please refer to [docs](https://docs.tensorplex.ai/tensorplex-docs/tensorplex-dojo-testnet/official-links).
90+
91+
1. Head to https://dojo.tensorplex.ai or https://dojo-testnet.tensorplex.ai and login and sign with your Metamask wallet.
92+
93+
- You'll see an empty homepage with no Tasks, and a "Connect" button on the top right ![image](./assets/ui/homepage.png)
94+
- Click on "Connect" and you'll see a popup with different wallets for you to connect to ![image](./assets/ui/wallet_popup.jpg)
95+
- Click "Next" and "Continue", then finally it will be requesting a signature from your wallet, please sign and it will be connected. ![image](./assets/ui/wallet_sign.jpg)
96+
- Once connected, the top navigation bar should display your wallet address. ![image](./assets/ui/wallet_connected.png)
97+
98+
2. Once connected, please stay connected to your wallet and click on "Enter Subscription Key". ![image](./assets/subscription/enter_subscription.png)
99+
100+
- Give your subscription a name, and enter your subscription key generated earlier before running the miner. _*Refer to step 4 of "Getting Started" if you need to retrieve your key*_ ![image](./assets/subscription/enter_details.png)
101+
- Click "Create" and your subscription will be saved. ![image](./assets/subscription/created_details.png)
102+
- Confirmed your subscription is created properly, and that you can view your tasks! ![image](./assets/subscription/tasks_shown.png)
103+
104+
# Dojo CLI
105+
106+
We provide a CLI that allows miners to manage their API and subscription keys either when connecting to our hosted Tensorplex API services or their own self-hosted miner backend.
107+
108+
Features:
109+
110+
- Tab completion
111+
- Prefix matching wallets
112+
113+
You may use the dockerized version of the CLI using
114+
115+
```bash
116+
make dojo-cli
117+
```
118+
119+
Alternatively you can simply run the CLI inside of a virtual environment
120+
121+
```bash
122+
# Start the dojo cli tool
123+
# Upon starting the CLI it will ask if you wanna use the default path for bittensor wallets, which is `~/.bittensor/wallets/`.
124+
# If you want to use a different path, please enter 'n' and then specify the path when prompted.
125+
dojo
126+
127+
# TIP: During the whole process, you could actually use tab-completion to display the options, so you don't have to remember them all. Please TAB your way guys! 🙇‍♂️
128+
# It should be prompting you to enter you coldkey and hotkey
129+
# After entering the coldkey and hotkey, you should be in the command line interface for dojo, please authenticate by running the following command.
130+
# You should see a message saying "✅ Wallet coldkey name and hotkey name set successfully."
131+
authenticate
132+
133+
# Afterwards, please generate an API Key with the following command.
134+
# You should see a message saying: "✅ All API keys: ['sk-<KEY>]". Displaying a list of your API Keys.
135+
api_key generate
136+
137+
# Lastly, please generate a Subscription Key with the following command.
138+
# You should see a message saying: "✅ All Subscription keys: ['sk-<KEY>]". Displaying a list of your Subscription Keys.
139+
subscription_key generate
140+
141+
# :rocket: You should now have all the required keys, and be able to start mining.
142+
143+
# Other commands available to the CLI:
144+
# You can always run the following command to get your current keys.
145+
api_key list
146+
subscription_key list
147+
148+
# You can also delete your keys with the following commands.
149+
api_key delete
150+
subscription_key delete
151+
```
152+
153+
# Recommended
154+
155+
## Auto-updates with Watchtower
156+
157+
It is recommended to run watchtower alongside your miner to automatically keep your containers up-to-date. Watchtower monitors running containers and automatically pulls and recreates them when it detects that the image has changed.
158+
159+
To start watchtower:
160+
161+
```bash
162+
make watchtower
163+
```
164+
165+
To stop watchtower:
166+
167+
```bash
168+
make watchtower-down
169+
```

‎README-validator.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Validating
2+
3+
> **Note:** To ensure your validator runs smoothly, enable the auto top-up feature for Openrouter, this ensures that your validator will not fail to call synthetic API during task generation. The estimate cost of generating a task is approximately $0.20 USD.
4+
5+
Before starting, create a .env file by making a copy of .env.example
6+
7+
```bash
8+
cp .env.example .env
9+
```
10+
11+
Complete the .env file by changing / uncommenting the required variables
12+
13+
| Variable | Description | Default Value | Remarks |
14+
|-------------------------|-------------------------------------------|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
15+
| BITTENSOR_DIR | Bittensor directory | $HOME/.bittensor | |
16+
| WALLET_COLDKEY | Bittensor coldkey name | - | |
17+
| WALLET_HOTKEY | Bittensor hotkey name | - | |
18+
| NETUID | Subnet ID | 52 | 52 for mainnet <br>98 for testnet |
19+
| SUBTENSOR_NETWORK | Network name | mainnet | finney (mainnet) <br>test (testnet) <br>local (local subtensor) |
20+
| SUBTENSOR_ENDPOINT | WebSocket endpoint for network connection | <wss://entrypoint-finney.opentensor.ai:443> | <wss://test.finney.opentensor.ai:443> for testnet <br><ws://mainnet-lite:9944> for local subtensor <br><ws://testnet-lite:9944> for local testnet subtensor |
21+
| OPENROUTER_API_KEY | OpenRouter API authentication key | - | OpenRouter API key |
22+
| SYNTHETIC_API_URL | Synthetic API service URL | <http://synthetic-api:5003> | Internal service endpoint |
23+
| LANGFUSE_SECRET_KEY | Langfuse secret key | - | Langfuse secret key |
24+
| LANGFUSE_PUBLIC_KEY | Langfuse public key | - | Langfuse public key |
25+
| LANGFUSE_HOST | Langfuse host URL | <https://us.cloud.langfuse.com> | Langfuse endpoint |
26+
| REDIS_HOST | Redis host | redis | Container name or IP |
27+
| REDIS_PORT | Redis port | 6379 | Default Redis port |
28+
| DB_HOST | Database host address | postgres:5432 | Format: hostname:port |
29+
| DB_NAME | Database name | db | Database Name |
30+
| DB_USERNAME | Database username | - | Database Username |
31+
| DB_PASSWORD | Database password | - | Database Password |
32+
| VALIDATOR_API_BASE_URL | Data Collection Endpoint | <https://dojo-validator-api.tensorplex.ai> | |
33+
| DOJO_LOKI_URL | Loki Endpoint | <https://dojo-logs.tensorplex.ai> | |
34+
| VALIDATOR_HOTKEY | SS58 Address for labelling | - | |
35+
36+
Start the validator
37+
38+
```bash
39+
# To start the validator:
40+
make validator
41+
```
42+
43+
To start with autoupdate for validators (**strongly recommended**), see the [Auto-updater](#auto-updater) section.
44+
45+
## Data Collection
46+
47+
To export all data that has been collected from the validator, ensure that you have the environment variables setup properly as in [validator-setup](#validating), then run the following:
48+
49+
```bash
50+
make validator-pull
51+
make extract-dataset
52+
```
53+
54+
# Recommended
55+
56+
## Auto-updates with Watchtower
57+
58+
It is recommended to run watchtower alongside your miner to automatically keep your containers up-to-date. Watchtower monitors running containers and automatically pulls and recreates them when it detects that the image has changed.
59+
60+
To start watchtower:
61+
62+
```bash
63+
make watchtower
64+
```
65+
66+
To stop watchtower:
67+
68+
```bash
69+
make watchtower-down
70+
```

‎README.md

+9-261
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,19 @@ For Docker installation, see https://docs.docker.com/engine/install/ for instruc
197197
For Docker Compose installation, see https://docs.docker.com/compose/install/linux for instructions
198198

199199
```bash
200-
# for linux, a convenience script is available
200+
# For linux, a convenience script is available
201201
./dojo/scripts/setup/install_docker.sh
202202

203-
# verify both docker and docker compose are installed
203+
# Verify both docker and docker compose are installed
204204
docker --version
205205
docker compose version
206206

207-
# for validator please install docker loki plugin
207+
# Validators, install docker loki plugin
208208
docker plugin install grafana/loki-docker-driver:3.3.2-amd64 --alias loki --grant-all-permissions
209209
```
210210

211211
4. Start local subtensor node (**optional**)
212-
> The included subtensor service only expose 30333 (p2p) to the public, 9933 and 9944 are only accesssible internally in the docker network, feel free to change the configuration if required.
212+
> The included subtensor service only expose 30333 (p2p) to the public, 9933 and 9944 are only accesssible internally in the docker network, feel free to change the configuration if required.
213213
214214
```bash
215215
# Mainnet
@@ -261,209 +261,8 @@ btcli s register --wallet.name coldkey --wallet.hotkey hotkey --netuid 52 --subt
261261
btcli s register --wallet.name coldkey --wallet.hotkey hotkey --netuid 98 --subtensor.network test
262262
```
263263

264-
## Mining
265-
266-
> **Note:** To connect to testnet, uncomment the testnet related configuration, specifically `NETUID`, `SUBTENSOR_CHAIN_ENDPOINT` and `SUBTENSOR_NETWORK`
267-
268-
### Option 1: Centralised Method
269-
270-
1. Create .env file with the following values first.
271-
272-
```bash
273-
# copy .env.miner.example
274-
cp .env.miner.example .env.miner
275-
276-
# ENV's that needs to be filled for miners:
277-
# for mainnet
278-
DOJO_API_BASE_URL="https://dojo-api.tensorplex.ai"
279-
# for testnet
280-
DOJO_API_BASE_URL="https://dojo-api-testnet.tensorplex.ai"
281-
DOJO_API_KEY= # blank for now
282-
WALLET_COLDKEY=# the name of the coldkey
283-
WALLET_HOTKEY=# the name of the hotkey
284-
AXON_PORT=8888 # port to serve requests over the public network for validators to call
285-
VALIDATOR_MIN_STAKE=20000 # minimum stake required for validators default is 20000 TAO (use this to bypass the blacklist function in testnet)
286-
# Task related config
287-
TASK_MAX_RESULT=4 # this means that each miner can have up to 4 workers fill in responses
288-
```
289-
290-
2. Run the CLI to retrieve API Key and Subscription Key, see [Dojo CLI](#dojo-cli) for usage.
291-
292-
```bash
293-
make dojo-cli
294-
295-
# remember to use tab completions to see list of commands
296-
# authenticate and generate keys
297-
authenticate
298-
api_key generate
299-
subscription_key generate
300-
301-
# list all keys
302-
api_key list
303-
subscription_key list
304-
```
305-
306-
3. Complete the .env file with the variables below:
307-
308-
```bash
309-
DOJO_API_KEY=# api key from step 2.
310-
```
311-
312-
4. Start the miner by running the following commands:
313-
314-
```bash
315-
make miner-centralised
316-
```
317-
318-
To start with autoupdate for miners (**strongly recommended**), see the [Auto-updater](#auto-updater) section.
319-
320-
### Option 2: Decentralised Method
321-
322-
1. Create .env file with the following values first.
323-
324-
```bash
325-
# copy .env.miner.example
326-
cp .env.miner.example .env.miner
327-
328-
# env vars that needs to be filled for miners:
329-
DOJO_API_BASE_URL="http://worker-api:8080" # use this value
330-
DOJO_API_KEY=# blank for now
331-
WALLET_COLDKEY=# the name of the coldkey
332-
WALLET_HOTKEY=# the name of the hotkey
333-
AXON_PORT=8888 # port to serve requests over the public network for validators to call
334-
# Task related config
335-
TASK_MAX_RESULT=4 # this means that each miner can have up to 4 workers fill in responses
336-
337-
# for dojo-ui
338-
NEXT_PUBLIC_BACKEND_URL=http://localhost:3000
339-
340-
# for dojo-worker-api
341-
REDIS_USERNAME=#set a non-default username
342-
REDIS_PASSWORD=#generate and set a secure password
343-
344-
# postgres details
345-
DB_HOST=postgres-miner:5432 # use this value
346-
DB_NAME=db
347-
DB_USERNAME=#set a non-default username
348-
DB_PASSWORD=#generate and set a secure password
349-
DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}
350-
351-
# aws credentials for S3
352-
AWS_ACCESS_KEY_ID=#get from aws
353-
AWS_SECRET_ACCESS_KEY=#get from aws
354-
AWS_S3_BUCKET_NAME=#get from aws
355-
S3_PUBLIC_URL=#s3 bucket url that can be accessed publicly
356-
357-
JWT_SECRET=# generate a random JWT key
358-
ETHEREUM_NODE=# get an ethereum endpoint URL from Infura, Alchemy or any other provider
359-
```
360-
361-
2. Start the worker api which will be connected to the CLI later.
362-
363-
```bash
364-
make miner-worker-api
365-
```
366-
367-
3. Run the CLI to retrieve API Key and Subscription Key, see [Dojo CLI](#dojo-cli) for usage.
368-
369-
```bash
370-
make dojo-cli
371-
```
372-
373-
4. Grab the API key and add it to your .env file
374-
375-
```bash
376-
DOJO_API_KEY=# api key from earlier
377-
```
378-
379-
5. Now, run the full miner service.
380-
381-
```bash
382-
make miner-decentralised
383-
```
384-
385-
To start with autoupdate for miners (**strongly recommended**), see the [Auto-updater](#auto-updater) section.
386-
387-
> [!IMPORTANT]
388-
>
389-
> Don't be alarmed that the status of the `prisma-setup-miner` service shows exit code 0. This means it ran successfully.
390-
>
391-
> Other services should also be healthy in order for the `miner-testnet-decentralised` service to run successfully.
392-
393-
### Setup Subscription Key for Labellers on UI to connect to Dojo Subnet for scoring
394-
395-
Note: URLs are different for testnet and mainnet. Please refer to [docs](https://docs.tensorplex.ai/tensorplex-docs/tensorplex-dojo-testnet/official-links).
396-
397-
1. Head to https://dojo.tensorplex.ai or https://dojo-testnet.tensorplex.ai and login and sign with your Metamask wallet.
398-
399-
- You'll see an empty homepage with no Tasks, and a "Connect" button on the top right ![image](./assets/ui/homepage.png)
400-
- Click on "Connect" and you'll see a popup with different wallets for you to connect to ![image](./assets/ui/wallet_popup.jpg)
401-
- Click "Next" and "Continue", then finally it will be requesting a signature from your wallet, please sign and it will be connected. ![image](./assets/ui/wallet_sign.jpg)
402-
- Once connected, the top navigation bar should display your wallet address. ![image](./assets/ui/wallet_connected.png)
403-
404-
2. Once connected, please stay connected to your wallet and click on "Enter Subscription Key". ![image](./assets/subscription/enter_subscription.png)
405-
406-
- Give your subscription a name, and enter your subscription key generated earlier before running the miner. _*Refer to step 4 of "Getting Started" if you need to retrieve your key*_ ![image](./assets/subscription/enter_details.png)
407-
- Click "Create" and your subscription will be saved. ![image](./assets/subscription/created_details.png)
408-
- Confirmed your subscription is created properly, and that you can view your tasks! ![image](./assets/subscription/tasks_shown.png)
409-
410-
## Validating
411-
412-
> **Note:** To connect to testnet, uncomment the testnet related configuration, specifically `NETUID`, `SUBTENSOR_CHAIN_ENDPOINT` and `SUBTENSOR_NETWORK`
413-
414-
Copy the validator .env file and set up the .env file
415-
416-
```bash
417-
# copy .env.validator.example
418-
cp .env.validator.example .env.validator
419-
420-
# edit the .env file with vim, vi or nano
421-
422-
WALLET_COLDKEY=# the name of the coldkey
423-
WALLET_HOTKEY=# the name of the hotkey
424-
VALIDATOR_API_BASE_URL=https://dojo-validator-api.tensorplex.ai
425-
426-
427-
# for dojo-synthetic-api
428-
OPENROUTER_API_KEY="sk-or-v1-<KEY>"
429-
430-
# for langfuse, the free tier is more than enough
431-
LANGFUSE_SECRET_KEY=# head to langfuse.com
432-
LANGFUSE_PUBLIC_KEY=# head to langfuse.com
433-
LANGFUSE_HOST="https://us.cloud.langfuse.com" # 🇺🇸 US region
434-
435-
436-
# postgres details for validator
437-
DB_HOST=postgres-vali:5432
438-
DB_NAME=db
439-
DB_USERNAME=#set a non-default username
440-
DB_PASSWORD=#generate and set a secure password
441-
DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}
442-
443-
# dojo loki
444-
DOJO_LOKI_URL=# get from TPLX TEAM
445-
VALIDATOR_HOTKEY=# your running validator hotkey address
446-
```
447-
448-
> **Note:** To ensure your validator runs smoothly, enable the auto top-up feature for Openrouter, this ensures that your validator will not fail to call synthetic API during task generation. The estimate cost of generating a task is approximately $0.20 USD.
449-
450-
Start the validator
451-
452-
```bash
453-
# To start the validator:
454-
make validator
455-
```
456-
457-
To start with autoupdate for validators (**strongly recommended**), see the [Auto-updater](#auto-updater) section.
458-
459-
## Data Collection
460-
461-
To export all data that has been collected from the validator, ensure that you have the environment variables setup properly as in [validator-setup](#validating), then run the following:
462-
463-
```bash
464-
make validator-pull
465-
make extract-dataset
466-
```
264+
## [For Miners](README-miner.md)
265+
## [For Validators](README-validator.md)
467266

468267
# Auto-updater
469268

@@ -479,62 +278,11 @@ Please ensure that you run the command in the python environment, if you haven't
479278
conda activate dojo_py311
480279

481280
# validator
482-
pm2 start auto_update.py --name auto-update-validator --interpreter $(which python3) -- --env_file .env.validator --service validator
483-
484-
# miner-centralised
485-
pm2 start auto_update.py --name auto-update-miner-centralised --interpreter $(which python3) -- --env_file .env.miner --service miner-centralised
281+
pm2 start auto_update.py --name auto-update-validator --interpreter $(which python3) -- ---service validator
486282

487-
# miner-decentralised
488-
pm2 start auto_update.py --name auto-update-miner-decentralised --interpreter $(which python3) -- --env_file .env.miner --service miner-decentralised
489-
```
490-
491-
# Dojo CLI
492-
493-
We provide a CLI that allows miners to manage their API and subscription keys either when connecting to our hosted Tensorplex API services or their own self-hosted miner backend.
494-
495-
Features:
496-
497-
- Tab completion
498-
- Prefix matching wallets
499-
500-
You may use the dockerized version of the CLI using
283+
# miner
284+
pm2 start auto_update.py --name auto-update-miner-centralised --interpreter $(which python3) -- --service miner
501285

502-
```bash
503-
make dojo-cli
504-
```
505-
506-
Alternatively you can simply run the CLI inside of a virtual environment
507-
508-
```bash
509-
# Start the dojo cli tool
510-
# Upon starting the CLI it will ask if you wanna use the default path for bittensor wallets, which is `~/.bittensor/wallets/`.
511-
# If you want to use a different path, please enter 'n' and then specify the path when prompted.
512-
dojo
513-
514-
# TIP: During the whole process, you could actually use tab-completion to display the options, so you don't have to remember them all. Please TAB your way guys! 🙇‍♂️
515-
# It should be prompting you to enter you coldkey and hotkey
516-
# After entering the coldkey and hotkey, you should be in the command line interface for dojo, please authenticate by running the following command.
517-
# You should see a message saying "✅ Wallet coldkey name and hotkey name set successfully."
518-
authenticate
519-
520-
# Afterwards, please generate an API Key with the following command.
521-
# You should see a message saying: "✅ All API keys: ['sk-<KEY>]". Displaying a list of your API Keys.
522-
api_key generate
523-
524-
# Lastly, please generate a Subscription Key with the following command.
525-
# You should see a message saying: "✅ All Subscription keys: ['sk-<KEY>]". Displaying a list of your Subscription Keys.
526-
subscription_key generate
527-
528-
# :rocket: You should now have all the required keys, and be able to start mining.
529-
530-
# Other commands available to the CLI:
531-
# You can always run the following command to get your current keys.
532-
api_key list
533-
subscription_key list
534-
535-
# You can also delete your keys with the following commands.
536-
api_key delete
537-
subscription_key delete
538286
```
539287

540288
# For Dojo developers

‎auto_update.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@
2525
CONFIG = {
2626
"validator": {
2727
"images": ["dojo-synthetic-api", "dojo"],
28-
"docker_compose_down": "docker compose --env-file .env.validator -f docker-compose.validator.yaml down",
29-
"docker_compose_up": "docker compose --env-file .env.validator -f docker-compose.validator.yaml up --build -d validator",
28+
"docker_compose_down": "docker compose -f docker-compose.validator.yaml down",
29+
"docker_compose_up": "docker compose -f docker-compose.validator.yaml up --build -d validator",
3030
},
31-
"miner-decentralised": {
31+
"miner": {
3232
"images": ["dojo-worker-api", "dojo-ui", "dojo"],
33-
"docker_compose_down": "docker compose --env-file .env.miner -f docker-compose.miner.yaml down",
34-
"docker_compose_up": "docker compose --env-file .env.miner -f docker-compose.miner.yaml up --build -d miner-decentralised",
35-
},
36-
"miner-centralised": {
37-
"services": [
38-
"miner-centralised",
39-
],
40-
"images": ["dojo"],
41-
"docker_compose_down": "docker compose --env-file .env.miner -f docker-compose.miner.yaml down",
42-
"docker_compose_up": "docker compose --env-file .env.miner -f docker-compose.miner.yaml up --build -d miner-centralised",
33+
"docker_compose_down": "docker compose -f docker-compose.miner.yaml down",
34+
"docker_compose_up": "docker compose -f docker-compose.miner.yaml up --build -d miner-decentralised",
4335
},
36+
# "miner-centralised": {
37+
# "services": [
38+
# "miner-centralised",
39+
# ],
40+
# "images": ["dojo"],
41+
# "docker_compose_down": "docker compose --env-file .env.miner -f docker-compose.miner.yaml down",
42+
# "docker_compose_up": "docker compose --env-file .env.miner -f docker-compose.miner.yaml up --build -d miner-centralised",
43+
# },
4444
}
4545

4646

‎docker-compose.miner.yaml

+18-185
Original file line numberDiff line numberDiff line change
@@ -2,216 +2,49 @@ x-logging: &default-logging
22
options:
33
max-size: "50m"
44

5-
volumes:
6-
postgres-miner-volume:
7-
redis-miner-volume:
8-
95
networks:
106
dojo-miner:
117
driver: bridge
8+
dojo-platform:
9+
name: dojo-platform
1210
# Applicable only for sidecar and miner service
1311
subtensor:
1412
name: subtensor
1513

1614
services:
17-
# ============== COMMON SERVICES ============== #
18-
19-
redis-miner:
20-
image: redis/redis-stack-server:7.4.0-v0
21-
env_file:
22-
- .env.miner
23-
expose:
24-
- 6379
25-
volumes:
26-
- redis-miner-volume:/data
27-
networks:
28-
- dojo-miner
29-
healthcheck:
30-
test: ["CMD", "redis-cli", "ping"]
31-
interval: 5s
32-
timeout: 5s
33-
retries: 5
34-
logging: *default-logging
35-
36-
postgres-miner:
37-
image: postgres:15.7
38-
env_file:
39-
- .env.miner
40-
# looks strange, but double $ (i.e. $$) for variable substitution
41-
command: >
42-
bash -c "
43-
export POSTGRES_USER=$${DB_USERNAME}
44-
export POSTGRES_PASSWORD=$${DB_PASSWORD}
45-
export POSTGRES_DB=$${DB_NAME}
46-
docker-entrypoint.sh postgres
47-
"
48-
expose:
49-
- 5432
50-
volumes:
51-
- postgres-miner-volume:/var/lib/postgresql/data
52-
networks:
53-
- dojo-miner
54-
healthcheck:
55-
test:
56-
# looks strange, but double $ (i.e. $$) for variable substitution
57-
["CMD-SHELL", "pg_isready -h postgres-miner -U $${DB_USERNAME}"]
58-
interval: 5s
59-
timeout: 5s
60-
retries: 5
61-
logging: *default-logging
62-
63-
prisma-setup-miner:
64-
platform: linux/amd64
65-
env_file:
66-
- .env.miner
67-
build:
68-
context: .
69-
dockerfile: ./docker/Dockerfile.prisma
70-
environment:
71-
DB_USERNAME: ${DB_USERNAME}
72-
DB_PASSWORD: ${DB_PASSWORD}
73-
DB_NAME: ${DB_NAME}
74-
DB_HOST: ${DB_HOST}
75-
DATABASE_URL: postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}
76-
working_dir: /app
77-
depends_on:
78-
- postgres-miner
79-
networks:
80-
- dojo-miner
81-
logging: *default-logging
82-
83-
sidecar:
84-
image: docker.io/parity/substrate-api-sidecar:v19.0.2
85-
env_file:
86-
- .env.miner
87-
read_only: true
88-
environment:
89-
SAS_SUBSTRATE_URL: ${SUBTENSOR_ENDPOINT:-wss://entrypoint-finney.opentensor.ai}
90-
SAS_EXPRESS_PORT: 8081
91-
expose:
92-
- 8081
93-
healthcheck:
94-
# jank since no curl
95-
test:
96-
[
97-
"CMD",
98-
"node",
99-
"-e",
100-
"const http = require('http'); const options = { hostname: '127.0.0.1', port: 8081, path: '/blocks/head', method: 'GET' }; const req = http.request(options, (res) => { process.exit(res.statusCode === 200 ? 0 : 1); }); req.on('error', (error) => { console.error(error); process.exit(1); }); req.end();",
101-
]
102-
interval: 12s
103-
timeout: 24s
104-
retries: 10
105-
start_period: 30s
106-
networks:
107-
- dojo-miner
108-
- subtensor
109-
logging: *default-logging
110-
111-
worker-api:
112-
platform: linux/amd64
113-
env_file:
114-
- .env.miner
115-
volumes:
116-
- ./.env.miner:/dojo-api/.env
117-
image: ghcr.io/tensorplex-labs/dojo-worker-api:main
118-
environment:
119-
RUNTIME_ENV: local
120-
SERVER_PORT: 8080
121-
SUBNET_UID: 98
122-
CORS_ALLOWED_ORIGINS: http://localhost*,http://worker-ui*,http://dojo-cli*
123-
SUBSTRATE_API_URL: sidecar:8081
124-
# authentication
125-
TOKEN_EXPIRY: 24
126-
REDIS_HOST: redis-miner
127-
REDIS_PORT: 6379
128-
VALIDATOR_MIN_STAKE: 20000
129-
ports:
130-
- "8080:8080"
131-
expose:
132-
- 8080
133-
depends_on:
134-
redis-miner:
135-
condition: service_healthy
136-
postgres-miner:
137-
condition: service_healthy
138-
sidecar:
139-
condition: service_healthy
140-
prisma-setup-miner:
141-
condition: service_completed_successfully
142-
command: ["./service", "--debug"]
143-
healthcheck:
144-
test: ["CMD", "curl", "-f", "http://localhost:8080"]
145-
interval: 10s
146-
timeout: 10s
147-
retries: 5
148-
start_period: 90s # seems too long but let's just give enough time so that healthcheck doesn't fail
149-
networks:
150-
- dojo-miner
151-
logging: *default-logging
152-
153-
worker-ui:
154-
image: ghcr.io/tensorplex-labs/dojo-ui:tensorplex-prod
155-
ports:
156-
- "3000:3000"
157-
healthcheck:
158-
test: ["CMD", "curl", "-f", "http://localhost:3000"]
159-
interval: 10s
160-
timeout: 10s
161-
retries: 5
162-
networks:
163-
- dojo-miner
164-
logging: *default-logging
15+
# watchtower:
16+
# extends:
17+
# file: docker-compose.shared.yaml
18+
# service: watchtower
16519

16620
dojo-cli:
21+
container_name: dojo-cli
16722
image: ghcr.io/tensorplex-labs/dojo:main
16823
volumes:
169-
- ./:/app
170-
- ./.env.miner:/app/.env
171-
- $HOME/.bittensor:/root/.bittensor
24+
- ./.env:/app/.env
25+
- $BITTENSOR_DIR:/root/.bittensor
17226
command: ["dojo-cli"]
17327
tty: true
17428
stdin_open: true
17529
networks:
17630
- dojo-miner
31+
- dojo-platform
17732

178-
# ============== MINER ============== #
179-
180-
miner-decentralised:
181-
image: ghcr.io/tensorplex-labs/dojo:main
182-
working_dir: /app
183-
env_file:
184-
- .env.miner
185-
volumes:
186-
- ./:/app
187-
- ./.env.miner:/app/.env
188-
- $HOME/.bittensor:/root/.bittensor
189-
command: ["miner"]
190-
depends_on:
191-
worker-api:
192-
condition: service_healthy
193-
worker-ui:
194-
condition: service_healthy
195-
ports:
196-
- ${AXON_PORT}:${AXON_PORT}
197-
networks:
198-
- dojo-miner
199-
- subtensor
200-
logging: *default-logging
201-
202-
miner-centralised:
33+
miner:
34+
container_name: miner
20335
image: ghcr.io/tensorplex-labs/dojo:main
204-
working_dir: /app
36+
labels:
37+
com.centurylinklabs.watchtower.enable: "true"
20538
env_file:
206-
- .env.miner
39+
- .env
20740
volumes:
208-
- ./:/app
209-
- ./.env.miner:/app/.env
210-
- $HOME/.bittensor:/root/.bittensor
41+
- ./.env:/app/.env
42+
- $BITTENSOR_DIR:/root/.bittensor
21143
command: ["miner"]
21244
ports:
21345
- ${AXON_PORT}:${AXON_PORT}
21446
networks:
21547
- dojo-miner
48+
- dojo-platform
21649
- subtensor
21750
logging: *default-logging

‎docker-compose.platform.yaml

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
x-logging: &default-logging
2+
options:
3+
max-size: "50m"
4+
5+
volumes:
6+
postgres-platform-volume:
7+
redis-platform-volume:
8+
9+
networks:
10+
dojo-platform:
11+
name: dojo-platform
12+
# Applicable only for sidecar and miner service
13+
subtensor:
14+
name: subtensor
15+
16+
services:
17+
redis:
18+
extends:
19+
file: docker-compose.shared.yaml
20+
service: redis
21+
volumes:
22+
- redis-platform-volume:/data
23+
networks:
24+
- dojo-platform
25+
26+
postgres:
27+
extends:
28+
file: docker-compose.shared.yaml
29+
service: postgres
30+
volumes:
31+
- postgres-platform-volume:/var/lib/postgresql/data
32+
networks:
33+
- dojo-platform
34+
35+
prisma-setup-platform:
36+
container_name: prisma-setup-platform
37+
platform: linux/amd64
38+
env_file:
39+
- .env
40+
build:
41+
context: .
42+
dockerfile: ./docker/Dockerfile.prisma
43+
working_dir: /app
44+
depends_on:
45+
- postgres
46+
networks:
47+
- dojo-platform
48+
logging: *default-logging
49+
50+
sidecar:
51+
container_name: substrate-sidecar
52+
image: docker.io/parity/substrate-api-sidecar:v19.3.1
53+
env_file:
54+
- .env
55+
read_only: true
56+
# environment:
57+
# SAS_SUBSTRATE_URL: ${SUBTENSOR_ENDPOINT:-wss://entrypoint-finney.opentensor.ai}
58+
# SAS_EXPRESS_PORT: 8081
59+
expose:
60+
- 8081
61+
healthcheck:
62+
# jank since no curl
63+
test:
64+
[
65+
"CMD",
66+
"node",
67+
"-e",
68+
"const http = require('http'); const options = { hostname: '127.0.0.1', port: 8081, path: '/blocks/head', method: 'GET' }; const req = http.request(options, (res) => { process.exit(res.statusCode === 200 ? 0 : 1); }); req.on('error', (error) => { console.error(error); process.exit(1); }); req.end();",
69+
]
70+
interval: 12s
71+
timeout: 24s
72+
retries: 10
73+
start_period: 30s
74+
networks:
75+
- dojo-platform
76+
- subtensor
77+
logging: *default-logging
78+
79+
worker-api:
80+
container_name: worker-api
81+
image: ghcr.io/tensorplex-labs/dojo-worker-api:main
82+
platform: linux/amd64
83+
env_file:
84+
- .env
85+
volumes:
86+
- ./.env:/dojo-api/.env
87+
ports:
88+
- "8080:8080"
89+
expose:
90+
- 8080
91+
depends_on:
92+
redis:
93+
condition: service_healthy
94+
postgres:
95+
condition: service_healthy
96+
sidecar:
97+
condition: service_healthy
98+
prisma-setup-platform:
99+
condition: service_completed_successfully
100+
command: ["./service", "--debug"]
101+
healthcheck:
102+
test: ["CMD", "curl", "-f", "http://localhost:8080"]
103+
interval: 10s
104+
timeout: 10s
105+
retries: 5
106+
start_period: 90s # seems too long but let's just give enough time so that healthcheck doesn't fail
107+
networks:
108+
- dojo-platform
109+
logging: *default-logging
110+
111+
worker-ui:
112+
container_name: worker-ui
113+
image: ghcr.io/tensorplex-labs/dojo-ui:tensorplex-prod
114+
ports:
115+
- "3000:3000"
116+
healthcheck:
117+
test: ["CMD", "curl", "-f", "http://localhost:3000"]
118+
interval: 10s
119+
timeout: 10s
120+
retries: 5
121+
networks:
122+
- dojo-platform
123+
logging: *default-logging

‎docker-compose.shared.yaml

+71-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,84 @@
1+
x-logging: &default-logging
2+
options:
3+
max-size: "50m"
4+
15
networks:
26
subtensor:
37
name: subtensor
48

59
services:
610
btcli:
11+
container_name: btcli
712
image: ghcr.io/tensorplex-labs/dojo:main
813
volumes:
9-
- ./:/app
10-
- $HOME/.bittensor:/root/.bittensor
14+
- $BITTENSOR_DIR:/root/.bittensor
1115
networks:
1216
- subtensor
1317
command: ["btcli"]
1418
tty: true
1519
stdin_open: true
20+
21+
redis:
22+
container_name: redis
23+
image: redis/redis-stack-server:7.4.0-v0
24+
env_file:
25+
- .env
26+
expose:
27+
- 6379
28+
command: >
29+
sh -c '
30+
if [ ! -z "$$REDIS_PASSWORD" ] && [ ! -z "$$REDIS_USERNAME" ]; then
31+
redis-stack-server --requirepass $$REDIS_PASSWORD &
32+
sleep 2
33+
redis-cli -a $$REDIS_PASSWORD ACL SETUSER $$REDIS_USERNAME on \>$$REDIS_PASSWORD allcommands allkeys
34+
wait
35+
else
36+
redis-stack-server;
37+
fi'
38+
healthcheck:
39+
test: >
40+
sh -c '
41+
if [ ! -z "$$REDIS_PASSWORD" ]; then
42+
redis-cli -a $$REDIS_PASSWORD ping;
43+
else
44+
redis-cli ping;
45+
fi'
46+
interval: 5s
47+
timeout: 5s
48+
retries: 5
49+
logging: *default-logging
50+
51+
postgres:
52+
container_name: postgres
53+
image: postgres:15.7
54+
env_file:
55+
- .env
56+
command: >
57+
bash -c "
58+
export POSTGRES_USER=$${DB_USERNAME}
59+
export POSTGRES_PASSWORD=$${DB_PASSWORD}
60+
export POSTGRES_DB=$${DB_NAME}
61+
docker-entrypoint.sh postgres
62+
"
63+
expose:
64+
- 5432
65+
healthcheck:
66+
test:
67+
# looks strange, but double $ (i.e. $$) for variable substitution
68+
["CMD-SHELL", "pg_isready -h postgres -U $${DB_USERNAME}"]
69+
interval: 5s
70+
timeout: 5s
71+
retries: 5
72+
logging: *default-logging
73+
74+
watchtower:
75+
container_name: watchtower
76+
image: containrrr/watchtower
77+
environment:
78+
- WATCHTOWER_CLEANUP=true
79+
- WATCHTOWER_DEBUG=true
80+
- WATCHTOWER_POLL_INTERVAL=600
81+
- WATCHTOWER_LABEL_ENABLE=true
82+
restart: always
83+
volumes:
84+
- /var/run/docker.sock:/var/run/docker.sock

‎docker-compose.validator.yaml

+48-76
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ volumes:
77
redis-validator-volume:
88
prisma-pip-cache:
99
prisma-binary:
10+
prisma-client:
1011

1112
networks:
1213
dojo-validator:
@@ -15,37 +16,36 @@ networks:
1516
name: subtensor
1617

1718
services:
18-
# ============== COMMON SERVICES ============== #
19-
redis-service:
20-
container_name: redis-service
21-
image: redis/redis-stack-server:7.4.0-v0
22-
env_file:
23-
- .env.validator
24-
expose:
25-
- 6379
19+
# watchtower:
20+
# extends:
21+
# file: docker-compose.shared.yaml
22+
# service: watchtower
23+
24+
redis:
25+
extends:
26+
file: docker-compose.shared.yaml
27+
service: redis
2628
volumes:
2729
- redis-validator-volume:/data
2830
networks:
2931
- dojo-validator
30-
healthcheck:
31-
test: ["CMD", "redis-cli", "ping"]
32-
interval: 5s
33-
timeout: 5s
34-
retries: 5
35-
logging: *default-logging
32+
33+
postgres:
34+
extends:
35+
file: docker-compose.shared.yaml
36+
service: postgres
37+
volumes:
38+
- postgres-validator-volume:/var/lib/postgresql/data
39+
networks:
40+
- dojo-validator
3641

3742
synthetic-api:
3843
container_name: synthetic-api
3944
image: ghcr.io/tensorplex-labs/dojo-synthetic-api:main
45+
labels:
46+
com.centurylinklabs.watchtower.enable: "true"
4047
env_file:
41-
- .env.validator
42-
environment:
43-
# leave env vars that'll never change down here, don't source any env vars
44-
# here because we're not looking in .env and variable substitution will
45-
# happen too early
46-
- REDIS_HOST=redis-service
47-
- REDIS_PORT=6379
48-
- REDIS_DB=0
48+
- .env
4949
expose:
5050
- 5003
5151
networks:
@@ -55,43 +55,15 @@ services:
5555
interval: 10s
5656
timeout: 10s
5757
retries: 5
58-
start_period: 30s
58+
start_period: 50s
5959
depends_on:
60-
redis-service:
60+
redis:
6161
condition: service_healthy
6262
# allow docker commands inside container
6363
volumes:
6464
- /var/run/docker.sock:/var/run/docker.sock
6565
logging: *default-logging
6666

67-
postgres-vali:
68-
container_name: postgres-vali
69-
image: postgres:15.7
70-
env_file:
71-
- .env.validator
72-
# looks strange, but double $ (i.e. $$) for variable substitution
73-
command: >
74-
bash -c "
75-
export POSTGRES_USER=$${DB_USERNAME}
76-
export POSTGRES_PASSWORD=$${DB_PASSWORD}
77-
export POSTGRES_DB=$${DB_NAME}
78-
docker-entrypoint.sh postgres
79-
"
80-
expose:
81-
- 5432
82-
volumes:
83-
- postgres-validator-volume:/var/lib/postgresql/data
84-
networks:
85-
- dojo-validator
86-
healthcheck:
87-
test:
88-
# looks strange, but double $ (i.e. $$) for variable substitution
89-
["CMD-SHELL", "pg_isready -h postgres-vali -U $${DB_USERNAME}"]
90-
interval: 5s
91-
timeout: 5s
92-
retries: 5
93-
logging: *default-logging
94-
9567
prisma-setup-vali:
9668
container_name: prisma-setup-vali
9769
platform: linux/amd64
@@ -101,37 +73,40 @@ services:
10173
command: >
10274
sh -c "prisma migrate deploy && prisma generate"
10375
env_file:
104-
- .env.validator
105-
working_dir: /app
76+
- .env
10677
volumes:
10778
- prisma-pip-cache:/root/.cache/pip
10879
- prisma-binary:/root/prisma-python
80+
- prisma-client:/app/database/prisma
10981
- ./:/app
11082
networks:
11183
- dojo-validator
11284
depends_on:
113-
- postgres-vali
85+
- postgres
11486
logging: *default-logging
11587

11688
validator:
11789
container_name: validator
11890
image: ghcr.io/tensorplex-labs/dojo:main
119-
working_dir: /app
91+
labels:
92+
com.centurylinklabs.watchtower.enable: "true"
93+
com.centurylinklabs.watchtower.depends-on: "synthetic-api,postgres"
12094
env_file:
121-
- .env.validator
95+
- .env
12296
volumes:
123-
- ./:/app
124-
- ./.env.validator:/app/.env
125-
- $HOME/.bittensor:/root/.bittensor
97+
- ./.env:/app/.env
98+
- $BITTENSOR_DIR:/root/.bittensor
12699
- prisma-binary:/root/prisma-python
100+
- prisma-pip-cache:/root/.cache/pip
101+
- prisma-client:/app/database/prisma
127102
command: ["validator"]
128103
networks:
129104
- dojo-validator
130105
- subtensor
131106
depends_on:
132107
synthetic-api:
133108
condition: service_healthy
134-
postgres-vali:
109+
postgres:
135110
condition: service_healthy
136111
prisma-setup-vali:
137112
condition: service_completed_successfully
@@ -146,7 +121,7 @@ services:
146121
container_name: validator-api-service
147122
image: ghcr.io/tensorplex-labs/dojo:main
148123
env_file:
149-
- .env.validator
124+
- .env
150125
ports:
151126
- "127.0.0.1:9999:9999"
152127
command: ["validator-api-service"]
@@ -156,51 +131,48 @@ services:
156131
container_name: extract-dataset
157132
image: ghcr.io/tensorplex-labs/dojo:main
158133
env_file:
159-
- .env.validator
134+
- .env
160135
command: ["extract-dataset"]
161136
networks:
162137
- dojo-validator
163138
volumes:
164-
- ./:/app
165-
- ./.env.validator:/app/.env
139+
- ./.env:/app/.env
166140
- prisma-binary:/root/prisma-python
167-
- $HOME/.bittensor:/root/.bittensor
141+
- $BITTENSOR_DIR:/root/.bittensor
168142
logging: *default-logging
169143

170144
migration:
171145
container_name: migration
172146
image: ghcr.io/tensorplex-labs/dojo:main
173147
platform: linux/amd64
174148
env_file:
175-
- .env.validator
176-
working_dir: /app
149+
- .env
177150
command: ["migration"]
178151
networks:
179152
- dojo-validator
180153
volumes:
181-
- ./:/app
182-
- ./.env.validator:/app/.env
154+
- ./.env:/app/.env
155+
- prisma-client:/app/database/prisma
183156
- prisma-binary:/root/prisma-python
184157
- prisma-pip-cache:/root/.cache/pip
185-
- $HOME/.bittensor:/root/.bittensor
158+
- $BITTENSOR_DIR:/root/.bittensor
186159
logging: *default-logging
187160

188161
validate-migration:
189162
container_name: validate-migration
190163
image: ghcr.io/tensorplex-labs/dojo:main
191164
platform: linux/amd64
192165
env_file:
193-
- .env.validator
194-
working_dir: /app
166+
- .env
195167
command: ["validate-migration"]
196168
networks:
197169
- dojo-validator
198170
volumes:
199-
- ./:/app
200-
- ./.env.validator:/app/.env
171+
- ./.env:/app/.env
172+
- prisma-client:/app/database/prisma
201173
- prisma-binary:/root/prisma-python
202174
- prisma-pip-cache:/root/.cache/pip
203-
- $HOME/.bittensor:/root/.bittensor
175+
- $BITTENSOR_DIR:/root/.bittensor
204176
logging: *default-logging
205177

206178
fill-score-column:

0 commit comments

Comments
 (0)
Please sign in to comment.