Skip to content
ocx
install

Examples

Three examples cover installs beyond a developer machine: a container image, a host with no registry access and a CI job. The installer output page shows a developer-machine install in each shell. Each example shows the command and what it prints. For GitHub Actions and GitLab, use the maintained integrations instead of the generic job below.

Install ocx into an image so every container starts with it on the path. Pin the installer and the ocx version, so a rebuild next month produces the same image. Set OCX_NO_MODIFY_PATH because a container has no interactive profile to edit.

FROM debian:12-slim
RUN apt-get update \
&& apt-get install --yes --no-install-recommends ca-certificates curl \
&& rm -rf /var/lib/apt/lists/*
ENV OCX_HOME=/opt/ocx
RUN curl -fsSL https://setup.ocx.sh/sh/0.2.2 | OCX_INSTALL_VERSION=0.6.5 OCX_NO_MODIFY_PATH=1 sh
ENV PATH="${OCX_HOME}/symlinks/ocx.sh/ocx/cli/current/content/bin:${PATH}"

Build the image and ask the installed ocx for its version:

Build and run the image
Terminal window
docker build --quiet --tag ocx-box . >/dev/null
docker run --rm ocx-box ocx version
0.6.5
Build an image with OCX installed

A host with no route to the OCX registry cannot run ocx self setup, which pulls the package store from the registry. Set OCX_INSTALL_NO_SETUP to place the ocx binary in the bin directory and skip that step. Point the installer at your internal mirror for the manifest and the archive. Copy the installer script to the host first, for example from https://setup.ocx.sh/archive/0.2.2/install.sh.

Terminal window
export OCX_HOME=/opt/ocx
export OCX_INSTALL_DIST_URL="https://mirror.corp.example/ocx/dist/${OCX_DIST_SHA256}.json"
export OCX_INSTALL_MIRROR_URL=https://mirror.corp.example/ocx/releases
export OCX_INSTALL_VERSION=0.6.5

Add OCX_INSTALL_PRINT_PATH to print the bin directory, and OCX_INSTALL_QUIET to keep informational messages off stderr:

Place the binary and print its directory
Terminal window
OCX_INSTALL_NO_SETUP=1 OCX_INSTALL_PRINT_PATH=1 OCX_INSTALL_QUIET=1 sh install.sh
/opt/ocx/symlinks/ocx.sh/ocx/cli/current/content/bin
Install OCX without ocx self setup

ocx self update does not manage a binary placed this way. Run the installer again with a new version to update it.

For a CI system with no maintained integration, call the installer in the job and put the bin directory on the path. With OCX_INSTALL_PRINT_PATH set, the bin directory is the last line of stdout, so tail -n1 captures it. The recording also shows the progress lines of ocx self setup. The session below leaves them out.

A pipeline in a POSIX shell reports the status of its last command, so check that the binary exists. Without the check, a failed download leaves BIN_DIR empty and the job continues.

Capture the bin directory in CI
Terminal window
BIN_DIR=$(curl -fsSL https://setup.ocx.sh/sh/0.2.2 | OCX_INSTALL_VERSION=0.6.5 OCX_INSTALL_PRINT_PATH=1 OCX_INSTALL_QUIET=1 sh | tail -n1)
test -x "$BIN_DIR/ocx" || {
echo "ocx install failed" >&2
exit 1
}
export PATH="$BIN_DIR:$PATH"
echo "$BIN_DIR"
/home/runner/.ocx/symlinks/ocx.sh/ocx/cli/current/content/bin
Capture the OCX bin directory in a CI job

The installer exits with a specific code for each failure kind. Exit codes and contract lists them for the job’s error handling.