Install and Configure the OCM CLI
The new major version of the OCM CLI is currently under active development. While we’re working on providing pre-built releases through various package managers and distribution channels, the only way to install the OCM CLI right now is to build it from source.
This guide will walk you through building the OCM CLI from the source code and configuring the necessary credentials.
Build from Source
Step 1: Clone the Repository
First, clone the OCM repository from GitHub:
git clone https://github.com/open-component-model/open-component-modelStep 2: Navigate to the CLI Directory
Change into the CLI directory:
cd open-component-model/cliStep 3: Build the CLI
Use the Task build tool to compile the OCM CLI:
task buildAfter the build completes successfully, you should see output similar to:
task: [build] ln -sf /path/to/your/open-component-model/cli/tmp/bin/ocm-<os>-<arch> /path/to/your/open-component-model/cli/tmp/bin/ocmThe exact path will vary depending on your system and where you cloned the repository.
Using the OCM CLI
Once the build is complete, you have three options for using the OCM CLI:
Option 1: Create a Permanent Alias
Add an alias to your shell configuration file for permanent access:
For Zsh users (~/.zshrc):
echo 'alias ocm="/path/to/your/open-component-model/cli/tmp/bin/ocm"' >> ~/.zshrc
source ~/.zshrcFor Bash users (~/.bashrc):
echo 'alias ocm="/path/to/your/open-component-model/cli/tmp/bin/ocm"' >> ~/.bashrc
source ~/.bashrcReplace /path/to/your/ with the actual path where you cloned the repository.
Option 2: Create a Session Alias
For temporary use in your current terminal session:
alias ocm="/path/to/your/open-component-model/cli/tmp/bin/ocm"Option 3: Use the Full Path
You can also run the OCM CLI directly using the full path:
/path/to/your/open-component-model/cli/tmp/bin/ocmVerify Installation
To verify that the OCM CLI is working correctly, run:
ocm versionThis should display the version information and confirm that the installation was successful.
Configure the OCM Command Line Client
Credentials to be used by the OCM CLI can be configured by supplying it with a
configuration file. By default, the CLI looks for the file in $HOME/.ocmconfig.
Using the Docker Configuration File
The easiest way to configure credentials for the OCM CLI is to reuse an existing Docker configuration json file.
Create a file named .ocmconfig in your home directory with the following content:
type: generic.config.ocm.software/v1
configurations:
- type: credentials.config.ocm.software
repositories:
- repository:
type: DockerConfig/v1
# The path to the Docker configuration file
dockerConfigFile: "~/.docker/config.json"
propagateConsumerIdentity: true
- type: attributes.config.ocm.software
attributes:
cache: ~/.ocm/cacheUsing Basic Authentication
Alternatively, you can use basic authentication. Create a file named .ocmconfig with the following content in your home directory:
type: generic.config.ocm.software/v1
configurations:
- type: credentials.config.ocm.software
consumers:
- identity:
type: ociRegistry
hostname: <YOUR-REGISTRY>/<YOUR-REPO> # e.g. ghcr.io/acme/acme
credentials:
- type: Credentials
properties:
username: <YOUR-USERNAME>
password: <YOUR-PASSWORD>More information on how to deal with credentials can be found in this guide with many examples for different repository types.
What’s Next?
Now that you have the OCM CLI installed and configured, you can start exploring its capabilities. Check out our Getting Started Guides to learn how to use the OCM CLI to work with your component.
Future Installation Methods
We’re actively working on providing more convenient installation methods, including:
- Homebrew packages
- Docker images
- Pre-built binaries for GitHub Releases
- and more
Stay tuned for updates as we continue to improve the installation experience!