Golem SDK CLI is a companion tool for the Golem SDK. It accelerates the creation and management of Golem JS projects.
Golem SDK CLI is available as an NPM package.
Install using npm:
npm install -g @golem-sdk/cli
Install using yarn:
yarn global add @golem-sdk/cli
To check if the installation was successful, run:
golem-sdk --version
After installation, the CLI is ready to be used.
If you want to install from source code or you would like to develop Golem SDK CLI, you can clone the repository and install dependencies:
git clone [email protected]:golemfactory/golem-sdk-cli.git
cd golem-sdk-cli/
npm install
To build the CLI, run:
npm run build
To make the CLI available in your system, run:
npm link
Now, the golem-sdk
command should be available in your system.
Golem SDK CLI is a companion tool for the Golem SDK. It is developed in parallel with the SDK, and new features are added as the SDK evolves or new use cases emerge
If you see a feature missing or a possible Golem SDK user experience improvement we could implement, please open an issue or a pull request.
The fastest way to get started with Golem Network is to use golem-sdk new
to create a new application from a template.
golem-sdk new
You will be asked a series of questions about your application and the CLI will use your answers to generate a new Golem Application.
The first question will be the project name. The CLI will use it to create a new directory for your application in the current directory. You can use the --path
option to override this behaviour.
Note: The command will abort if the directory already exists.
You can provide all the needed information from command line too. Type golem-sdk new --help
to see the list of available options.
Golem Manifest is a JSON document that describes your Golem application. While it is not necessary for simple applications, you will need it if you want to access advanced features of the Golem SDK, like access to the Internet (outbound).
The golem-sdk
CLI allows users to create and update the manifest file. By default, it assumes the manifest is available in a manifest.json
file in the current folder. If you want to point to a different file, use the --manifest (or -m) option.
To create a new Golem Manifest with the golem-sdk
CLI, run:
golem-sdk manifest create <image> [--image-hash hash]
The image
argument should identify the GVMI image used by your application. The tools accept a few formats which are explained in the table below. You can learn more about Golem images here.
If you have a package.json
file in your project, the tool will use the name
, version
, and description
fields from the file to fill in the fields in the manifest. Otherwise, you will need to provide them manually.
The manifest needs to contain the image URL pointing to the GVMI download location and its hash to validate its integrity.
To facilitate the process of creating a manifest, golem-sdk
accepts multiple forms of image argument, where some of them will automatically resolve the URL and/or hash.
Please consult the table below for more details:
Argument format | Example | Is --image-hash required? |
Notes |
---|---|---|---|
Image tag | golem/node:latest |
No, it will be automatically resolved. | Image hash is fetched from [https://registry.golem.network]. It is the recommended method. |
Image hash | 3d6c48bb4c192708168d53cee4f36876b263b7745c3a3c239c6749cd |
No, it is resolved from the image argument. | Image URL will point to [https://registry.golem.network] |
URL to registry.golem.network | https://registry.golem.network/v1/image/download?tag=golem-examples/blender:2.80&https=true |
No, it is automatically resolved. | |
URL to arbitrary download location | https://example.com/my-image |
Yes, image-hash is required. | Image is calculated by the gvmkit-build conversion tool. |
If the hash is not provided or resolved, you will get a warning that the manifest will not be usable until you provide it manually.
For your application to access the Internet from the Golem network, the manifest must include the outbound URLs the application will be using.
The default set of URLs that providers may allow your application to use is available (here). Note providers can modify the content of the list.
This command will update the manifest file with the provided URL:
golem-sdk manifest net add-outbound https://golem.network
You can use this command multiple times to add additional URLs to the manifest or pass many URLs in a single run:
This command will update the manifest file with all the URLs provided.
golem-sdk manifest net add-outbound https://golem.network https://github.com https://example.com
If the provider has set up an audited-payload rule for URLs not on the whitelist, you can gain access to these URLs. However, they must be declared in the manifest, and the manifest is signed by the key linked with the certificate accepted by the provider.
To sign the manifest, run:
golem-sdk manifest sign -k <private-key>
If your private key is encrypted, you will need to provide the correct passphrase (-p
or --passphrase
option).
This command will produce a signature file (by default manifest.sig
) that you will need to use in your application.
You can verify the manifest signature with your certificate using the following command:
golem-sdk manifest verify
By default, it will use manifest.pem
as the certificate file and manifest.sig
as the signature file. You can change that by using the --certificate-file
and --signature-file
options.
On success, it will print the following message:
Manifest matches signature.
It is important to use this command to make sure the key you are using is compatible with your certificate.
The run-on-golem
command allows you to run an image on the Golem Network without the need to create a full Golem application.
Now you can test, debug and validate images without having to writing a single line of code.
By default, run-on-golem
will try to use your manifest file from the current directory. You can override this behaviour by using the --manifest
option
or by providing the --image
option.
Example:
golem-sdk run-on-golem --image=golem/node:20-alpine
Once you run the command, the CLI will deploy the image to one of the providers and you will be presented with an interactive shell. You can type ?
in order to get a list of all available commands.
Within the shell, you can quickly test your application by running commands on the image, as well as uploading and downloading files.
You can run commands without an interactive shell ether by passing the commands you want to run using the --execute
option or using a batch file:
Examples:
golem-sdk run-on-golem --execute "upload localfile.txt /golem/input; run 'ls /golem/input'"
golem-sdk run-on-golem batchfile.txt
If you'd like to contribute to the project, you can fork the repository and create a Pull Request. Code contributions are warmly welcomed.
Please make sure the code follows the coding style as configured in .eslintrc
and .prettierrc
.
The Pull Request should describe what changes you've made, what's the purpose of them and how to use them.
- Project homepage: https://github.com/golemfactory/golem-sdk-cli
- Repository: https://github.com/golemfactory/golem-sdk-cli
- Issue tracker: https://github.com/golemfactory/golem-sdk-cli/issues
- In case of sensitive bugs like security vulnerabilities, please contact us directly through our contact form instead of using the issue tracker. We value your effort to improve the security and privacy of this project!
- Golem, a global, open-source, decentralized supercomputer that anyone can access.
- Golem Image Registry
- Golem Discord
- Documentation:
- QuickStart for JavaScript developers
- Have a look at the most important concepts behind any Golem application: Golem application fundamentals
- Learn about preparing your custom Docker-like images.
- Related projects:
The code in this project is licensed under the GPL-3 license.
See LICENSE for more information.