Skip to content

CI/CD Integration

You can automate deployments to Zerokie by pushing a Docker image to a container registry and then calling the Zerokie API (or CLI) to redeploy. This guide shows complete pipeline configs for GitLab CI and GitHub Actions.

Before setting up your pipeline you need:

  • A Zerokie app already created via the CLI or API (see First Deploy)
  • Your Docker image published to a container registry (GitLab Container Registry, GitHub Container Registry, Docker Hub, etc.)
  • A Zerokie API key stored as a CI/CD secret variable named ZEROKIE_API_KEY

Add a .gitlab-ci.yml to the root of your repository:

stages:
- build
- deploy
variables:
IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
build:
stage: build
image: docker:latest
services:
- docker:dind
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $IMAGE .
- docker push $IMAGE
deploy:
stage: deploy
image: alpine:latest
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- apk add --no-cache curl
- curl -fsSL https://releases.zerokie.com/install.sh | sh
- zerokie login --api-key "$ZEROKIE_API_KEY"
- zerokie apps deploy my-app --image "$IMAGE"

Replace my-app with your actual app name. Store your API key in Settings > CI/CD > Variables as ZEROKIE_API_KEY.

Create .github/workflows/deploy.yml in your repository:

name: Build and Deploy
on:
push:
branches: [main]
env:
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
push: true
tags: ${{ env.IMAGE }}
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Install Zerokie CLI
run: curl -fsSL https://releases.zerokie.com/install.sh | sh
- name: Deploy to Zerokie
run: |
zerokie login --api-key "$ZEROKIE_API_KEY"
zerokie apps deploy my-app --image "$IMAGE"
env:
ZEROKIE_API_KEY: ${{ secrets.ZEROKIE_API_KEY }}
IMAGE: ${{ env.IMAGE }}

Replace my-app with your actual app name. Add your API key in Settings > Secrets and variables > Actions as ZEROKIE_API_KEY.

If you prefer raw API calls over the CLI, you can call the deploy endpoint directly with curl:

Terminal window
curl -sf -X POST \
https://api.platform-dev.zerokie.com/v1/apps/my-app/deploy \
-H "Authorization: Bearer $ZEROKIE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"image\": \"$IMAGE\"}"

See the API Reference for details on the request body.

The CI/CD pipeline redeploys an existing app — it does not create one. Before your first pipeline run, create the app once:

Terminal window
zerokie apps create \
--name my-app \
--image my-registry.com/my-app:latest \
--port 3000

After this initial creation, every push to main will build, push, and redeploy automatically.

If your Docker image is stored in a private registry, pass the registry credentials during deployment so Zerokie can pull the image.

GitLab CI — add the registry flags to your deploy step:

deploy:
stage: deploy
image: alpine:latest
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- apk add --no-cache curl
- curl -fsSL https://releases.zerokie.com/install.sh | sh
- zerokie login --api-key "$ZEROKIE_API_KEY"
- >-
zerokie apps deploy my-app
--image "$IMAGE"
--registry-username "$CI_REGISTRY_USER"
--registry-password "$CI_REGISTRY_PASSWORD"
--registry-url "$CI_REGISTRY"

GitHub Actions — add the registry flags to your deploy step:

- name: Deploy to Zerokie
run: |
zerokie login --api-key "$ZEROKIE_API_KEY"
zerokie apps deploy my-app \
--image "$IMAGE" \
--registry-username "$REGISTRY_USERNAME" \
--registry-password "$REGISTRY_PASSWORD" \
--registry-url ghcr.io
env:
ZEROKIE_API_KEY: ${{ secrets.ZEROKIE_API_KEY }}
IMAGE: ${{ env.IMAGE }}
REGISTRY_USERNAME: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

Store your registry credentials as CI/CD secret variables — never hard-code them in your pipeline config.