Skip to content

Commit dfe0af0

Browse files
committed
improve docs, build.py and remove Makefile
1 parent aa9255e commit dfe0af0

File tree

5 files changed

+47
-58
lines changed

5 files changed

+47
-58
lines changed

.dockerignore

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
**/target/
2-
**/*.rs.bk
3-
**/Dockerfile
4-
**/.dockerignore
5-
**/.git
6-
**/.gitignore
7-
**/tmp
8-
**/Cargo.lock
9-
.docker/
1+
target
2+
.git

Makefile

Lines changed: 0 additions & 11 deletions
This file was deleted.

build-tools/docker/BUILD.md

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,38 @@
22

33
This document outlines the steps to build Docker images for the Mintlayer node daemon, wallet-cli, and node-gui.
44

5-
Before building make sure you clone the repository and change directory in the root of the repository.
5+
Before building make sure you clone the repository and change the current directory in the root of the repository.
66

7+
# The python build script
78

8-
## Building the Node Daemon Docker Image
9-
10-
To build the Docker image for the node daemon, follow these steps:
9+
Make sure you have python installed together with the `toml` package, you may want to create a specific environment:
1110

1211
```bash
13-
docker build -f docker/Dockerfile.node-daemon -t node-daemon .
12+
python3 -m venv env
13+
source env/bin/activate
14+
python3 -m pip install --upgrade pip
15+
python3 -m pip install toml
1416
```
1517

16-
17-
## Building the Wallet-CLI Docker Image
18-
19-
To build the Docker image for the wallet-cli, follow these steps:
18+
In order to build the images run:
2019

2120
```bash
22-
docker build -f docker/Dockerfile.wallet-cli -t wallet-cli .
21+
python3 build-tools/docker/build.py
2322
```
2423

24+
NOTE: to change the version of the images use the `-version` flag such as `--version=1.2.3`.
2525

26-
## Building the Node-GUI Docker Image
27-
28-
Node-gui is a graphical interface that runs the node itself in the background.
29-
To build the Docker image for the node-gui, follow these steps:
26+
For verifing images are built with use the following command:
3027

3128
```bash
32-
docker build -f docker/Dockerfile.node-gui -t node-gui .
29+
docker images | grep mintlayer
3330
```
3431

32+
The result should similar to the following:
3533

36-
37-
## Verify the builds
38-
39-
Once the build process finishes, you can verify the image was created successfully by running:
40-
41-
```bash
42-
docker images
34+
```
35+
$ docker images |grep mintlayer
36+
mintlayer/wallet-cli 0.1.1 57dcc4898a30 2 minutes ago 125MB
37+
mintlayer/node-gui 0.1.1 a2ed3937e081 2 minutes ago 290MB
38+
mintlayer/node-daemon 0.1.1 ad830bf576e3 3 minutes ago 119MB
4339
```

build-tools/docker/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ docker run -d -p 3030:3030 -p 13031:13031 --network=mintlayer-net --name mintlay
2727
```
2828

2929
The `-v` option is used to mount a local directory (in this case `~/.mintlayer`) as a volume in the Docker container.
30-
The `--user` option is used to specify the user that will write the `~/.mintlayer` directory.
31-
NOTE: this wont work on windows hosts.
30+
The `--user` option is used to specify the user that will write to the `~/.mintlayer` directory.
31+
NOTE: this won't work on windows hosts.
3232

3333
If you want to display logs you can pass the `-e RUST_LOG=info` argument, such as:
3434

@@ -61,4 +61,3 @@ docker run -it --network=mintlayer-net -v ~/.mintlayer:/root/.mintlayer mintlaye
6161
replace `<NETWORK>` with `mainnet` or `testnet` depending on what network you're running and `<IP_ADDRESS>` with the result of the command above.
6262

6363
This command mounts the same `~/.mintlayer` directory as a volume in the `wallet-cli` container and uses the `--rpc-cookie-file` option to specify the path to the cookie file.
64-

build-tools/docker/build.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,22 @@ def get_cargo_version(cargo_toml_path):
1919

2020
return version
2121

22-
def build_docker_image(dockerfile_path, image_name, version):
23-
# Docker build command
24-
command = f"docker build -t {image_name}:{version} -f {dockerfile_path} ."
2522

26-
# Run the command
27-
process = subprocess.Popen(command, shell=True)
28-
output, error = process.communicate()
23+
def build_docker_image(dockerfile_path, image_name, version, num_jobs=None):
24+
# Docker build command
25+
command = f"docker build -t {image_name}:{version} -f {dockerfile_path}"
26+
if num_jobs:
27+
command += f" --build-arg NUM_JOBS={num_jobs}"
28+
command += " ."
2929

30-
if error:
31-
print(f"Error occurred: {error}")
32-
else:
30+
try:
31+
# Run the command
32+
subprocess.check_call(command, shell=True)
3333
print(f"Built {image_name}:{version} successfully.")
34+
catch:
35+
print(f"Error occurred: {error}")
36+
exit(1) # stop the build
37+
3438

3539
def push_docker_image(image_name, version, latest=False):
3640
# Docker tag command
@@ -53,6 +57,7 @@ def push_docker_image(image_name, version, latest=False):
5357
if latest:
5458
print(f"Pushed {latest_image_name} successfully.")
5559

60+
5661
def delete_docker_image(image_name, version):
5762
# Full image name
5863
full_image_name = f"{image_name}:{version}"
@@ -67,33 +72,40 @@ def delete_docker_image(image_name, version):
6772
except subprocess.CalledProcessError:
6873
print(f"Failed to delete {full_image_name}.")
6974

70-
def build_instances(version):
71-
build_docker_image("build-tools/docker/Dockerfile.builder", "mintlayer-builder", "latest")
75+
76+
def build_instances(version, num_jobs=None):
77+
build_docker_image("build-tools/docker/Dockerfile.builder", "mintlayer-builder", "latest", num_jobs)
7278
build_docker_image("build-tools/docker/Dockerfile.node-daemon", "mintlayer/node-daemon", version)
7379
build_docker_image("build-tools/docker/Dockerfile.node-gui", "mintlayer/node-gui", version)
7480
build_docker_image("build-tools/docker/Dockerfile.wallet-cli", "mintlayer/wallet-cli", version)
7581
delete_docker_image("mintlayer-builder", "latest")
7682

83+
7784
def push_instances(version, latest):
7885
push_docker_image("mintlayer/node-daemon",version , latest)
7986
push_docker_image("mintlayer/node-gui",version , latest)
8087
push_docker_image("mintlayer/wallet-cli",version , latest)
8188

89+
8290
def main():
8391
parser = argparse.ArgumentParser()
8492
parser.add_argument('--push', action='store_true', help='Push the Docker image to Docker Hub')
8593
parser.add_argument('--latest', action='store_true', help='Tag the Docker image as latest while pushing')
8694
parser.add_argument('--build', type=lambda x: (str(x).lower() == 'true'), default=True, help="Set to false avoid the build")
95+
parser.add_argument('--version', help='Override version number', default=None)
96+
parser.add_argument('--num_jobs', help='Number of parallel jobs, defaults to # of CPUs', default=None)
8797
args = parser.parse_args()
88-
version = get_cargo_version("Cargo.toml")
98+
99+
version = args.version if args.version else get_cargo_version("Cargo.toml")
89100

90101
if args.build:
91-
build_instances(version)
102+
build_instances(version, num_jobs)
92103

93104
# Only push the image if the --push flag is provided
94105
if args.push:
95106
latest = args.latest
96107
push_instances(version, latest)
97108

109+
98110
if __name__ == "__main__":
99111
main()

0 commit comments

Comments
 (0)