Golem VM Image builder.
Project description
gvmkit-build
Golem VM Image builder used as companion app for Golem Registry: https://registry.golem.network
Requirements
Running docker engine is required. Tool supports Linux, Windows and macOS. Note that when using macOS ARM version use --platform linux/amd64 option for docker builds.
Installation
You can install gvmkit-build using pip (python3 with pip installer is required)
pip install gvmkit-build
or install form npm (npm installation is required)
npm install -g gvmkit-build
or install using cargo (Rust toolchain is required, a bit slow because it compiles from sources)
cargo install gvmkit-build
or download prebuild from github releases page:
https://github.com/golemfactory/gvmkit-build-rs/releases
or build from sources, you can find binary in target/release/gvmkit-build (or gvmkit-build.exe on Windows)
cargo build --release
Images
Golem Network is using gvmi images as base for creating VMs for tasks. These images are basically squashfs images with some additional metadata. They can be prepared from docker images using this (gvmkit-build) tool.
Quick start
-
Make sure your docker service is running and you have gvmkit-build installed
-
Go to the folder with your dockerfile and run
docker build . -t my_image
- Create account on registry portal https://registry.golem.network
Let's assume your user name is golem
- Create repository on registry portal
Let's assume you created repository named my_example
-
Create and copy personal access token from registry portal
-
Run (you will be asked for login and personal access token)
gvmkit-build my_image --push-to golem/my_example:latest
- Your tag
golem/my_example:latest
is ready to use in one of Golem Network APIs
Naming image
The tool as main argument takes docker image name.
Docker image name can be resolved using ImageId + tag or Repository name + tag.
Repository name can be composed of maximum two parts: <username>/<repository>
Examples:
python
resolves to python:latest
python:3.8
resolves to python:3.8
golemfactory/blender
resolves to golemfactory/blender:latest
You can also use image id instead of name, use docker image ls
to find your image id.
Following command will build image and create *.gvmi file in current directory.
gvmkit-build <image_name>
If image not exist locally the tool is trying to pull it from docker hub.
To use it in Golem Network, you have to upload it to registry portal.
To successfully add image to registry portal you have to name image accordingly or use
gvmkit-build <user_name>/<image_name>:<tag> --push
or if your local image name is not compatible use
gvmkit-build <docker_image_id> --push-to <user_name>/<image_name>:<tag>
Build process explained a bit
Tool is creating new container and is copying data from given image to new container. After copying is finished mksquashfs command is used inside tool container to create squashfs image. After adding metadata *.gvmi file is created and tool container removed. Note that tool image will stay downloaded on your machine for future use (it is quite small so no worry about disk space)
[Optional] - building squashfs-tools image
If you want to use your own tool without pulling from dockerhub: Go to squashfs-tools directory and run
docker build . -t my_squash_fs_builder
add environment variable to .env in folder where you run gvmkit-build
SQUASHFS_IMAGE_NAME=my_squash_fs_builder
For managing docker images and containers bollard library is used. https://docs.rs/bollard/latest/bollard/
Troubleshooting login to registry portal
The tool is using https://registry.golem.network as default registry portal.
You can change this behaviour by setting REGISTRY_URL
environment variable.
You should create account on registry portal and generate access token for your user.
If you really don't want to create account you can use anonymous upload (see section below about anonymous upload).
The tool will ask for login when --login --push or --push-to option is specified.
For storing login information rpassword library is used: https://docs.rs/crate/rpassword/latest
Only one instance of login/token is kept saved at "gvmkit-build-rs/default". So if you login with new user/token old pair will be forgotten.
This option will ask for login to registry portal
gvmkit-build --login
You can use command for check if your login information is correct
gvmkit-build --login-check
If you want to forget your login information you can use, it will clear your login information
gvmkit-build --logout
Above command are optional, because you will be asked for login automatically if you use --push or --push-to option.
On some systems when no secure store is provided you will be forced to use following method of keeping login/token pair. You can optionally put them in .env file from convenience in your working directory. Remember to set proper permissions to the file (chmod 600 .env) if using on shared machine.
REGISTRY_USER=<username-in-registry-portal>
REGISTRY_TOKEN=<access-token-generated-in-registry-portal>
When REGISTRY_USER/REGISTRY_TOKEN is set in environment variables, secure rpassword storage won't be used.
Uploading to multiple tags
The tool cannot upload to multiple tags, but you can call it multiple times with different tags. All steps of operations are cached so no worry about re-uploading same file multiple times.
Uploading large files
The tool is using chunked upload with default chunk size 10MiB for images greater than 500MiB (changing not recommended). Four upload workers are created by default (you can increase/decrease number of workers using --upload-workers argument depending on your network conditions). If you think your upload is stuck you can always stop and run tool again to finish download. Only chunks that were not uploaded will be uploaded again.
Note: Total limit of chunks is set to 1000 (so around 10GB by default). If you want to upload larger file you have to set greater chunk size accordingly.
Uploading image without login
You can upload images anonymously. Note that lifetime of such images is limited, and they can be removed from registry portal after some time without notice
cargo run --release -- <image_name> --push --nologin
Uploading image without building part
If you are sure that you have proper *.gvmi file for example my-test.gvmi you can use
gvmkit-build --direct-file-upload my-test.gvmi --push-to <user_name>/<image_name>:<tag>
or anonymously
gvmkit-build --direct-file-upload my-test.gvmi --push --nologin
Changing squashfs options when creating image
You can change compression used in mksquashfs to produce more or less compact images.
Look for help for more information. Note that currently zstd is not supported by Golem Network (you can use xz instead for extra compact images).
gvmkit-build --help
Integration with scripts
Use --extra-json-info-path=my-output.json to save additional information about image in json format.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file gvmkit_build-0.3.19-py3-none-win_amd64.whl
.
File metadata
- Download URL: gvmkit_build-0.3.19-py3-none-win_amd64.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 516576d97cb4dce84d668c152926fb8f118355c3faaa0aed86a09c457a1e1f8f |
|
MD5 | 0989e78ea8aed16598b8f7c7f57a9984 |
|
BLAKE2b-256 | baac4b709eef9e94371a7a5c08269f7c1267eb674be79c15e76342d3b4f97e0a |
File details
Details for the file gvmkit_build-0.3.19-py3-none-musllinux_1_2_x86_64.whl
.
File metadata
- Download URL: gvmkit_build-0.3.19-py3-none-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 3.8 MB
- Tags: Python 3, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e3839489431c5bd7209de96f08cf13ea13c59b98da9f07575189170b6b65d3c |
|
MD5 | 55a82c0c5f61b3342f99ad4d38613ab7 |
|
BLAKE2b-256 | cfea76b4e5acc412118202d26ef5fbf59cb7f0e491558ded3d2e61a54a7c77de |
File details
Details for the file gvmkit_build-0.3.19-py3-none-musllinux_1_2_aarch64.whl
.
File metadata
- Download URL: gvmkit_build-0.3.19-py3-none-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 3.6 MB
- Tags: Python 3, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40e456c44183226d2d9e79b4cbeb3989b99e3bfd1861004535eccf25864da665 |
|
MD5 | 03ce9de9e35a65d4f492338e1dff37c8 |
|
BLAKE2b-256 | 02a25fda07a4cd66845c1e6e85535bd69d515e36b03d7df230aaaec52c27c417 |
File details
Details for the file gvmkit_build-0.3.19-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gvmkit_build-0.3.19-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.7 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87ecf14c6ef8436b21c05f4f9f7c2cbd6f5d23a06ba6128230b22e530b04260c |
|
MD5 | a0cfc7b14a7e8a88ae15183c6553b5b4 |
|
BLAKE2b-256 | a4cb06b10b4bc19373c37b3461ac55cafc597090f19a57cf7dbd8520ee4eeaa8 |
File details
Details for the file gvmkit_build-0.3.19-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gvmkit_build-0.3.19-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.6 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6496ff7efc2288ff0c33a74f50d98319e54cf5a81137ee7ff4d62eca1c324c04 |
|
MD5 | c19fcb83a18798dc6b61c69399bf2d7e |
|
BLAKE2b-256 | 6cbffcdffd29a82323905b452b31074837e2e97f8f3b1d5cc6e131461a9fc58b |
File details
Details for the file gvmkit_build-0.3.19-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: gvmkit_build-0.3.19-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 3.8 MB
- Tags: Python 3, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d4a1e11f28aea9b2127385ff86f9a28cb760e7be699d9129c968a665fb834f5 |
|
MD5 | 702f6870417ace7e54b0dab8bc27a686 |
|
BLAKE2b-256 | 46a26ae3f74bebad004d9dd7900dd8c7428ed767458780da020704f094280712 |
File details
Details for the file gvmkit_build-0.3.19-py3-none-macosx_11_0_arm64.whl
.
File metadata
- Download URL: gvmkit_build-0.3.19-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.4 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35c3ac30a037bbc6203de95315992949f0e9c3ed7a0ad6abadfa1d2e9d920c3c |
|
MD5 | e2a0dcd0230e24f7692bf9d10a96120b |
|
BLAKE2b-256 | d78eb34abfacb3cef6117ea06207a217be6f4690d7eaf36f223b9450b711c01b |
File details
Details for the file gvmkit_build-0.3.19-py3-none-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: gvmkit_build-0.3.19-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb98960ec4e30d9748812c49e0c1c307c21d66f4ff256d9ad9ff68a50331b062 |
|
MD5 | ba23f032d42df208c0cc0e89a46ac214 |
|
BLAKE2b-256 | 0b062bd7d499fb31038a8df8df3d5bd0c5aa05375fa6122e4861296bedf47857 |