All documentation

Deploy a prebuilt image from CI

Private registries (ghcr.io, GitLab, Docker Hub), a GitHub Actions and GitLab CI step, and uc deploy --image.

Already building images in GitHub Actions or GitLab CI? Send us the finished image. There is nothing to rebuild on our side. A container gets the new image: the node pulls it and recreates the container, and the old one keeps running until the pull finishes. An app gets a new release from the image, with health check, zero-downtime switch and rollback to the previous release.

1. Credentials for a private registry

Public images are pulled without a login, so they don't need this step.

Open Account → Image registries → Add registry:

RegistryAddressUsernamePassword
GitHub (ghcr.io)ghcr.ioyour GitHub loginclassic token with read:packages
GitLabregistry.gitlab.com or your GitLab addressdeploy token namedeploy token with read_registry
Docker Hubdocker.ioDocker Hub loginRead-only access token
Your own registryreg.example.uz or reg.example.uz:5000usernamepassword

Click Check login. A mark appears next to the registry once it accepts the credentials.

The password is stored encrypted, and neither the panel nor the API ever shows it back. The node decrypts it right before a pull and passes it to Docker with that one request. It never goes to docker login, the Docker config or logs. Use read-only tokens: a pull needs nothing more.

2. Choose the registry on the resource

  • Container. In the create wizard, enter your image, for example ghcr.io/org/api:1.0, and pick the registry in the Registry field. For an existing container, change the registry in its settings.
  • App. Pass the registry together with the image when you deploy (registry in the API, --registry in uc). It is remembered for later deploys.

Credentials only work for their own host: a ghcr.io login is never sent to another server.

3. API token

Account → API tokens, scope Full access (write). Store it in your CI secrets as UC_TOKEN and the panel address as UC_URL.

GitHub Actions

name: deploy
on:
  push:
    branches: [main]
jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v4
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - id: push
        uses: docker/build-push-action@v6
        with:
          push: true
          tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
      - name: Deploy to UniCloud
        env:
          UC_URL: ${{ secrets.UC_URL }}
          UC_TOKEN: ${{ secrets.UC_TOKEN }}
        run: |
          curl -fsS -X POST "$UC_URL/api/v1/workloads/<resource id>/deploy" \
            -H "Authorization: Bearer $UC_TOKEN" \
            -H "Content-Type: application/json" \
            -H "Idempotency-Key: ${{ github.sha }}" \
            -d '{"image": "ghcr.io/${{ github.repository }}@${{ steps.push.outputs.digest }}"}'

A digest reference (@sha256:…) is safer than a tag: it runs exactly the image this job built. Image names on ghcr.io are lowercase, so if your repository name has capitals, set the image name explicitly.

GitLab CI

deploy:
  stage: deploy
  image: docker:27
  services: [docker:27-dind]
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA" .
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"
    - >
      wget -qO- --header "Authorization: Bearer $UC_TOKEN" --header "Content-Type: application/json"
      --post-data "{\"image\": \"$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA\"}"
      "$UC_URL/api/v1/workloads/<resource id>/deploy"
  only: [main]

Our node needs the deploy token with read_registry that you added in step 1. CI_REGISTRY_PASSWORD is only valid while the job runs, so it won't work for us.

Command line

uc deploy my-api --image ghcr.io/org/api@sha256:… --registry ghcr.io

--registry takes a registry id (rg_…), its address from your account settings, or none for a public image. Without the flag, the resource keeps the registry already chosen for it. For an app, the command prints the release log. For a container, it waits until the new image is running. Use --json in scripts.

How it is protected

The Docker daemon on a node is shared by many customers. That is why a container only runs from an image the node pulled for that resource, with your credentials or anonymously. The pull is the access check. The node tags the image with its own tag based on the digest the registry returned, and starts the container only from that tag. An image another customer already has on the node is never given to you without a pull, and the same holds the other way round.

A few more rules:

  • the names uc/… and uc-… belong to the platform and can't be used;
  • internal network addresses and localhost are not accepted as registries;
  • a pull is limited to 20 minutes, and it is cut off if the registry sends nothing for 3 minutes.