Files
ci-templates/docs/docker.md
2025-11-11 02:29:49 +03:00

3.0 KiB

Docker CI documentation

To build docker images, and deploy them using helm values, you can connect CI templates from this repository to your project.

NOTE: Before you begin, make sure you've enabled Actions in your app and deploy repo

User/Organization setup (Required only once per user/organization)

NOTE: If you set it up for an organization, use organization settings page instead of user profile settings

NOTE 2: Of course you can configure all variables and secrets at the project level if you want

  1. Generate a new SSH key pair ssh-keygen -t ed25519 -f ./deploy -C "mymail@mysite.com""
  2. Go to your deploy repo settings, navigate to "Deploy keys" tab and add your public SSH key you've generated at step 1. This key will get access only to this repository. DO NOT FORGET to also enable "Enable Write Access" option!
  3. Go to your profile settings, expand "Actions" tab, go to "Secrets". Add a secret named DEPLOY_REPO_SSH_KEY and paste the private SSH key you've generated at step 1.
  4. Navigate to "Applications" tab. Press "Generate a new token". You need "write:package" and "write:repository" permissions.
  5. Return back to "Actions/Secrets" tab, and add a secret named REGISTRY_ACCESS_TOKEN you've created at step 3.
  6. Navigate to "Actions/Variables" tab, add a variable named DEPLOY_REPO and add path to your deploy repository which contains helm values for your application. It should have the following format: owner/reponame for example mooncat/deploy

Project setup (Required once per project)

  1. Navigate to your project's source code repository settings
  2. Navigate to "Actions/Variables" tab. Add a variable named VALUES_FILE_PATH which contains the path to the helm values file where the tag should be updated. For example, generic/values/myapp.yaml
  3. Also add a variable named TAG_PROPERTY_PATH which contains the jsonpath to the image tag property inside the values yaml file. For example, .generic.image.tag

Inside your project, create a file named .gitea/workflows/build.yaml with the following content:

name: Build and deploy application
on:
  push:
    branches:
      - master
      - main
  workflow_dispatch: {}

jobs:
  build:
    name: Build docker image
    uses: public/ci-templates/.gitea/workflows/docker_build.yaml@v1
    secrets:
      registry_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}

  deploy:
    name: Deploy application
    uses: public/ci-templates/.gitea/workflows/helm_values_deploy.yaml@v1
    with:
      version: ${{ needs.build.outputs.version }}
      deploy_repo: ${{ vars.DEPLOY_REPO }}
      values_file_path: ${{ vars.VALUES_FILE_PATH }}
      tag_property_path: ${{ vars.TAG_PROPERTY_PATH }}
    secrets:
      deploy_repo_ssh_key: ${{ secrets.DEPLOY_REPO_SSH_KEY }}
    needs: build

There are also inputs that contain default values. You can look them up in docker_build.yaml and helm_values_deploy.yaml files.