Guides

Release from any CI

Let GitLab CI, Jenkins or any other CI build the image and release it with a deploy token, then roll out exactly that digest. The token is valid for one app and lives as a secret in your CI.

Currently available on selected dedicated instances. Coming to the shared platform next.

With the trigger Pipeline, your own CI builds the image, pushes it into the project’s registry and tells nyxory which commit and digest go live. This works from any CI that can run a command: GitLab CI, Jenkins, Gerrit with Zuul, a runner of your own. nyxory does not have to reach your Git or your CI for it, the pipeline calls nyxory.

The pipeline signs in with a deploy token. A project admin creates it in the console, and you store it as a secret in your CI. If your code is on GitHub, use Release from GitHub Actions instead: it needs no stored secret.

GitHub Actions Pipeline (deploy token)
CI system GitHub Actions any
How the pipeline signs in GitHub OIDC token, nothing stored deploy token as a secret in your CI
What the sign-in is bound to repository, branch, environment one app
Connected repo required, through the nyxory GitHub App not required
What the history shows GitHub login and a link to the run the token’s name

Set it up

The trigger sits on the app page in the console, in the Auto-deploy panel:

  1. Deploy the app once, as usual through your coding agent. The image for it may come from somewhere else, for example a public image as a placeholder: nyxory does not have to build your code itself. The pipeline rolls new images into an existing app, it does not create one.
  2. Switch the trigger to Pipeline (deploy token). Only project admins can, and only on instances where registry access is set up. Otherwise the switch is greyed out, with the reason next to it.
  3. Create a deploy token in the same panel: a name that tells you which pipeline it is, and a validity (30, 90 or 365 days, or no expiry). The token is shown exactly once. nyxory stores only its hash.
  4. Store the token in your CI as a masked variable NYX_TOKEN. In GitLab under Settings → CI/CD → Variables, with Masked and preferably Protected.
  5. Copy the steps for the pipeline. They are the steps below, with your project, app and API URL filled in.

Once the trigger is Pipeline, nyxory stops building the app itself, also on a push. Only releases from your pipeline roll it out.

The steps

# NYX_TOKEN comes from your CI's secret store.
export NYX_API_URL=https://api.<instance>.nyxory.eu   # exactly your instance's API URL
COMMIT=$(git rev-parse HEAD)
REPO=$(nyx registry login nyx-abc123 web)
docker build -t "$REPO:$COMMIT" . && docker push "$REPO:$COMMIT"
# your scan, SBOM and signature on the pushed digest
DIGEST=$(docker inspect --format '{{index .RepoDigests 0}}' "$REPO:$COMMIT" | cut -d@ -f2)
nyx release nyx-abc123 web --commit "$COMMIT" --image "$REPO@$DIGEST"

Replace nyx-abc123 with your project ID and web with the app’s name. The job needs the nyx CLI, git and docker. What the parts do:

  • NYX_TOKEN is the deploy token. The CLI reads it from the environment, it never appears on a command line.
  • nyx registry login asks nyxory for push access for this run, logs Docker in with the password on stdin, and prints the repository to push to.
  • The build pushes the image tagged with the commit SHA, so every image in the registry traces back to its commit.
  • Your checks run on the pushed digest. If one fails, the job ends before anything is rolled out.
  • nyx release requests the release of this commit with this digest and waits until it is live. --commit is required here and must be the full 40-character SHA. --image must be pinned by digest (<repository>@sha256:…).

Pass the project ID (nyx-…), not the display name: resolving a name needs a lookup the deploy token can’t make.

nyx release exits 0 when the release is live and 1 when it failed or was refused, superseded or replaced, with status and reason printed. It exits 2 when the release is still running after --timeout (default 15m). The release then continues on nyxory. With --no-wait the job ends once the release is accepted.

Example: GitLab CI

# .gitlab-ci.yml
release:
  stage: deploy
  image: docker:27
  services: [docker:27-dind]
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  variables:
    NYX_API_URL: https://api.<instance>.nyxory.eu
  script:
    - apk add --no-cache bash curl
    - curl -fsSL https://nyxory.com/install.sh | NYX_INSTALL_ONLY=1 bash
    - REPO=$(nyx registry login nyx-abc123 web)
    - docker build -t "$REPO:$CI_COMMIT_SHA" .
    - docker push "$REPO:$CI_COMMIT_SHA"
    - DIGEST=$(docker inspect --format '{{index .RepoDigests 0}}' "$REPO:$CI_COMMIT_SHA" | cut -d@ -f2)
    - nyx release nyx-abc123 web --commit "$CI_COMMIT_SHA" --image "$REPO@$DIGEST"

NYX_TOKEN is not in the file, GitLab passes the masked variable into the job. The rule runs the job on the default branch only. Which branch may release is yours to set in your CI: with a deploy token nyxory sees no branch.

docker:dind needs a runner with privileged = true. If your runner is not privileged, such as a self-hosted one with default settings, build without a Docker daemon, see Without Docker in the job.

Without Docker in the job

Kaniko, Buildah and Podman build without a Docker daemon. nyx registry login then writes the credential into a Docker configuration instead of calling docker login:

nyx registry login nyx-abc123 web --docker-config /kaniko/.docker

The credential is then in config.json in that directory, other entries of the file stay. Kaniko reads /kaniko/.docker/config.json, Buildah and Podman read ~/.docker/config.json. Take the digest for nyx release from your builder’s output.

With and without a connected repo

The trigger Pipeline needs no repo connected to the app.

  • Without a connected repo a release only swaps the image. Every container of the app that already uses an image from the app’s repository in the project registry gets the new digest. If the app has exactly one container, it gets the image even when it has used an image from somewhere else so far: this is how the first release from the pipeline takes over an app that was deployed with a placeholder. nyxory does not read deploy/, and the commit only appears in the history.
  • With a connected repo, through the nyxory GitHub App or an HTTPS connection, nyxory also applies deploy/ from the release’s commit, see Configure your app from the repo. The commit has to be in that repo.

If, without a connected repo, the app has several containers and none uses an image from this repository, the choice would be a guess. nyxory then refuses the release with image_not_in_app. Deploy the image from your pipeline once through your coding agent, that is <repository>@sha256:… from nyx registry login and the push. From then on every release swaps the digest again.

Deploy tokens

  • A token is valid for one app. It fetches registry access for this app, requests a release and asks for its status. Every other API call refuses it, the release history and pausing included.
  • Only under the trigger Pipeline. When somebody switches the trigger back, the token is refused with trigger_not_pipeline.
  • At most 10 tokens per app. Give each pipeline its own, then the history shows which one released.
  • Revoking is for project admins, in the console, and takes effect at once. To rotate, create the new token, store it in your CI and revoke the old one.
  • No rights beyond those of the person who created it. When that person loses the admin role in the project, releases stop with token_principal_lost.

The history is on the app page under Releases. A release from the pipeline names the commit, the image and the token’s name.

Roll back

A rollback is a release of an earlier state and works as with GitHub Actions: from the console, with the CLI and a user token, or through your coding agent, see Roll back. A rollback from the console pauses automatic releases. While they are paused, a release from the pipeline is refused with releases_paused until a project admin resumes them. A deploy token cannot pause releases.

When a release is refused

Every refusal has its own code. nyx release prints it with the message and a hint.

Code HTTP Meaning Fix
unauthorized 401 the token is unknown, expired, revoked or belongs to another app check NYX_TOKEN, project and app, or create a new token
trigger_not_pipeline 409 the app’s trigger is not Pipeline a project admin switches it in the console
token_principal_lost 403 the person who created the token is no longer an admin of the project a project admin creates a new token
invalid_commit 422 --commit is not a full 40-character SHA pass the full SHA, for example git rev-parse HEAD
image_outside_project 422 the image is not in the project’s registry or not pinned by digest pass the repository from nyx registry login with the pushed digest
image_not_found 422 the digest is not in the registry push first
image_not_in_app 422 without a connected repo: the app has several containers and none uses an image from this repository deploy the image once, see With and without a connected repo
releases_paused 409 releases are paused after a rollback a project admin resumes them
too_many_tokens 409 the app already has 10 deploy tokens revoke one
registry_unavailable 503 the registry is not reachable or not set up on this instance retry later or ask us to set it up
too_many_credentials 429 the project already has 10 active registry credentials retry later, they expire within the hour
rate_limited 429 more than 30 release requests per app and minute retry in a minute

How access is secured

  • One secret that you manage. Unlike with GitHub Actions, a token lives in your CI here. Mask it, give it an expiry and limit it to protected branches. Whoever holds the token can release this one app until it expires or is revoked.
  • The token proves no run. Commit and branch are what the pipeline says. Which branch releases and who approves first is yours to rule in your CI.
  • nyxory stores only the hash. The token cannot be read again after it was created.
  • A short-lived registry credential. It is issued per run, may only push and pull in the project’s registry and is valid for at most 70 minutes.
  • Images only from the project’s registry. Images from other registries are refused, because the scan and the bill of materials per digest need the image there, see Security scanning.

Related: Release from GitHub Actions · Deploy on push · Configure your app from the repo · nyx CLI reference

Ask any AI about nyxory