- Get started
- Examples
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 in a Dockerfile
Section titled “Install in a Dockerfile”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-slimRUN apt-get update \ && apt-get install --yes --no-install-recommends ca-certificates curl \ && rm -rf /var/lib/apt/lists/*ENV OCX_HOME=/opt/ocxRUN curl -fsSL https://setup.ocx.sh/sh/0.2.2 | OCX_INSTALL_VERSION=0.6.5 OCX_NO_MODIFY_PATH=1 shENV PATH="${OCX_HOME}/symlinks/ocx.sh/ocx/cli/current/content/bin:${PATH}"Build the image and ask the installed ocx for its version:
docker build --quiet --tag ocx-box . >/dev/nulldocker run --rm ocx-box ocx version0.6.5Install on an air-gapped host
Section titled “Install on an air-gapped host”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.
export OCX_HOME=/opt/ocxexport OCX_INSTALL_DIST_URL="https://mirror.corp.example/ocx/dist/${OCX_DIST_SHA256}.json"export OCX_INSTALL_MIRROR_URL=https://mirror.corp.example/ocx/releasesexport OCX_INSTALL_VERSION=0.6.5Add OCX_INSTALL_PRINT_PATH to print the bin directory, and OCX_INSTALL_QUIET to keep informational messages off stderr:
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/binocx self update does not manage a binary placed this way.
Run the installer again with a new version to update it.
Install in a generic CI job
Section titled “Install in a generic CI job”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.
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/binThe installer exits with a specific code for each failure kind. Exit codes and contract lists them for the job’s error handling.