Skip to content

Commit 58aaa59

Browse files
authored
Merge pull request #110 from RedTeamSubnet/dev
documentation to clarify and streamline the process for building and publishing a miner solution as a Docker image.
2 parents e349681 + a15b3a9 commit 58aaa59

4 files changed

Lines changed: 177 additions & 42 deletions

File tree

docs/miner/workflow/2.develop-solution.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ Start implementing your own solution for the chosen challenge. Refer to the chal
5151

5252
Templates:
5353

54-
- **Auto Browser Sniffer Challenge**: <https://github.com/RedTeamSubnet/ab-sniffer-challenge/tree/main/templates/commit>
55-
- **Anti-Detect Automation Challenge**: <https://github.com/RedTeamSubnet/ada-detection-challenge/tree/main/templates/commit>
56-
- **Humanize Behavior Challenge**: <https://github.com/RedTeamSubnet/humanize-behaviour-challenge/tree/main/templates/commit>
54+
- **Auto Browser Sniffer Challenge**: <https://github.com/RedTeamSubnet/ab-sniffer-challenge/tree/main/examples/miner_commit>
55+
- **Anti-Detect Automation Challenge**: <https://github.com/RedTeamSubnet/ada-detection-challenge/tree/main/examples/miner_commit>
56+
- **Humanize Behavior Challenge**: <https://github.com/RedTeamSubnet/humanize-behaviour-challenge/tree/main/examples/miner_commit>
5757

58-
Navigate to the `templates/commit` directory in the cloned challenge repository to find the template structure for your solution as commit:
58+
Navigate to the `examples/miner_commit` directory in the cloned challenge repository to find the template structure for your solution as commit:
5959

6060
```sh
61-
cd ./templates/commit
61+
cd ./examples/miner_commit
6262

6363
# Start developing your solution here
6464
```
6565

66-
Then implement your solution in there or copy that `templates/commit` directory to your working location as solution, you need that `commit` directory structure for submission later.
66+
Then implement your solution in there or copy that `examples/miner_commit` directory to your working location as solution, you need that `miner_commit` directory structure for submission later.
6767

6868
## 2.4. Test your solution against challenge
6969

docs/miner/workflow/3.build-and-publish.md

Lines changed: 169 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,72 +5,207 @@ tags: [build, submit, docker, commit, publish]
55

66
# 3. 🏗 Build and Publish
77

8-
In this step, you will build your solution into a Docker image, publish it to Docker Hub, and obtain the SHA256 digest required for submission.
8+
In this step, you will build your solution into a Docker image, publish it to Docker Hub, and obtain the **SHA256 digest** required for submission.
9+
10+
---
911

1012
## Prerequisites
1113

1214
- [**1. Preparation**](./1.preparation.md)
1315
- [**2. Develop Solution**](./2.develop-solution.md)
1416

15-
## 3.1. Build docker image
17+
---
18+
19+
## 3.1 Initialize & Start Environment
20+
21+
!!! tip "Run First"
22+
Before building your final image, ensure the environment is running correctly with the default template.
23+
24+
This confirms the connection between the **challenge container** and the **miner container**.
25+
26+
### 1. Activate the Miner Service
27+
28+
Copy the development compose override to the project root:
29+
30+
~~~bash
31+
cp templates/compose/compose.override.dev.yml compose.override.yml
32+
~~~
33+
34+
### 2. Start Services
35+
36+
Run the compose helper script:
37+
38+
~~~bash
39+
./compose.sh start
40+
~~~
41+
42+
### 3. Confirm Execution
43+
44+
Verify both services are running.
45+
46+
Run:
47+
48+
~~~bash
49+
docker ps -a
50+
~~~
51+
52+
You should see two containers:
1653

17-
This step assumes you've already cloned the challenge repository and implemented your solution in the `templates/commit` directory or in your working directory as mentioned in the [previous step](./2.develop-solution.md).
54+
- `challenge-api`
55+
- `miner-commit-api`
1856

19-
!!! note "Arguments"
20-
Make sure to replace the placeholders:
57+
---
58+
59+
## 3.2 Configure & Build Miner Image
60+
61+
You must **claim the miner image** by updating it with your own Docker Hub information and building it using the correct context.
2162

22-
- `<USERNAME>` with your Docker Hub username.
23-
- `<REPO_NAME>` with your repository name on Docker Hub.
24-
- `<VERSION>` with your version tag (e.g., `1.0.0`, `v1`, etc.).
63+
!!! danger "DO NOT BUILD FROM THE ROOT DIRECTORY"
64+
Do **not** run the following command from the project root:
2565

26-
```sh
27-
docker build -t <USERNAME>/<REPO_NAME>:<VERSION> .
28-
# For example:
29-
docker build -t my_username/my_repo:1.0.0 .
66+
```bash
67+
docker build .
3068
```
3169

32-
!!! danger "IMPORTANT"
33-
To prevent submission theft, please don't include the challenge name or your Discord username in the image name. This precaution is necessary because multiple miners can locate your image on Docker Hub and submit it on your behalf.
70+
This will either fail or build the wrong image.
3471

35-
## 3.2. Publish docker image
72+
Always build through **Docker Compose**, which ensures the correct build context:
3673

37-
### 3.2.1. Create Docker Hub account
74+
```
75+
cd ./examples/miner_commit
76+
```
77+
78+
```bash
79+
docker compose build miner-commit-api
80+
```
81+
82+
---
3883

39-
Sign up at <https://hub.docker.com>, if you don't have an account yet.
84+
=== "Step 1 — Update compose.override.yml"
4085

41-
### 3.2.2. Docker Login
86+
Locate the `miner-commit-api` service and update the **image field** to your Docker Hub repository.
4287

43-
You need to login using your Docker Hub credentials before pushing the image:
88+
!!! warning "Crucial: Do Not Edit Challenge API"
89+
Only modify the **image field under `miner-commit-api`**.
90+
91+
Do **not** change anything inside the `challenge-api` service.
92+
93+
```yaml
94+
miner-commit-api:
95+
# CHANGE THIS to your Docker Hub repository
96+
image: <USERNAME>/<REPO_NAME>:<VERSION>
97+
98+
# DO NOT CHANGE THIS (points to your solution code)
99+
build:
100+
context: ./examples/miner_commit
101+
```
102+
103+
=== "Step 2 — Build Miner Image"
104+
105+
Build **only the miner container**:
106+
107+
```bash
108+
docker compose build miner-commit-api
109+
```
44110

45-
```sh
111+
This builds your solution container using the correct directory.
112+
113+
!!! danger "Prevent Submission Theft"
114+
Do **not** include the challenge name or your Discord username in the image name.
115+
116+
Other miners can scan Docker Hub and submit your image on your behalf.
117+
118+
## 3.3 Verify Locally (Sanity Check)
119+
120+
Before publishing your image, confirm that the container is running with **your custom image name**.
121+
122+
### 1. Restart Services
123+
124+
~~~bash
125+
./compose.sh restart
126+
~~~
127+
128+
### 2. Verify the Image
129+
130+
Run:
131+
132+
~~~bash
133+
docker ps -a
134+
~~~
135+
136+
Check the **IMAGE** column for the miner container.
137+
138+
!!! success "Correct"
139+
`miner-commit-api` shows:
140+
141+
**`<USERNAME>/<REPO_NAME>:<VERSION>`**
142+
143+
!!! failure "Wrong"
144+
It shows:
145+
146+
**`redteamsubnet61/rest-my-challenge`**
147+
148+
This means you are accidentally running the **challenge image** instead of your **miner solution**.
149+
150+
---
151+
152+
## 3.4 Publish Docker Image
153+
154+
### 3.4.1 Create Docker Hub Account
155+
156+
Create an account if you do not already have one:
157+
158+
<https://hub.docker.com>
159+
160+
### 3.4.2 Docker Login
161+
162+
Authenticate with Docker Hub:
163+
164+
~~~bash
46165
docker login
47-
```
166+
~~~
167+
168+
### 3.4.3 Push Docker Image
48169

49-
### 3.2.3. Push docker image to Docker Hub
170+
Push your image to Docker Hub:
50171

51-
```sh
172+
~~~bash
52173
docker push <USERNAME>/<REPO_NAME>:<VERSION>
53-
# For example:
174+
~~~
175+
176+
Example:
177+
178+
~~~bash
54179
docker push my_username/my_repo:1.0.0
55-
```
180+
~~~
56181

57-
### 3.2.4. Get SHA256 digest as commit hash
182+
### 3.4.4 Get SHA256 Digest (Commit Hash)
58183

59184
!!! warning "FOR SUBMISSION"
60-
Save the SHA256 digest of your pushed docker image, which is required for submission for **miner commit hash**!
185+
Save the **SHA256 digest** of your pushed Docker image.
186+
187+
This value is required as your **miner commit hash** when submitting your solution.
188+
189+
Run:
61190

62-
```sh
191+
~~~bash
63192
docker inspect --format='{{index .RepoDigests 0}}' <USERNAME>/<REPO_NAME>:<VERSION>
64-
# For example:
193+
~~~
194+
195+
Example:
196+
197+
~~~bash
65198
docker inspect --format='{{index .RepoDigests 0}}' my_username/my_repo:1.0.0
66-
```
199+
~~~
67200

68-
Output:
201+
Example output:
69202

70-
```sh
203+
~~~
71204
my_username/my_repo@sha256:abc123def456...
72-
```
205+
~~~
206+
207+
---
73208

74-
## Next step
209+
## Next Step
75210

76211
- [**4. Submit Commit**](./4.submit-commit.md)

0 commit comments

Comments
 (0)