Codefresh Steps: Reusable Code for Common Operations
This page provides code you can use to perform common operations in the Codefresh CI/CD platform.
24.8M

Build a Docker image build

Build a Dockerfile and push it to the internal Codefresh registry.

arguments

  • build_arguments - A set of Docker build arguments to pass to the build process.
  • buildx - Build and push Docker images with Buildx including multi-platform builds (set to `true` to enable with default configuration, or set to an object with custom configuration). more info
  • disable_push - Do not push to any registry automatically.
  • dockerfile - The path to the Dockerfile from which the image is built. The default is Dockerfile.
  • image_name - The name for the image you build.
  • no_cache - Disable Docker engine cache for the build. more info
  • no_cf_cache - Disable Codefresh build optimization for the build. more info
  • platform - Set target platform/s (comma separated list) for build.
  • provider - Define if to build image with Codefresh, the default, or with an external provider such as Google Cloud Build (gcb). If not used, the pipeline builds the image locally on the pipeline pod. gcb requires additional arguments: google_app_creds, cache - both repo and ttl, timeout, machineType, logsBucket, and diskSizeGb . See example for details.
  • registry - The registry logical name of one of the inserted registries from the integration view.
  • registry_contexts - The registry logical name of one of the inserted registries from the integration view. The default values is primary registries by domain. Note that this is needed to do docker login to specified registries.
  • squash - Squash newly built layers into a single new layer.
  • tag - The tag that is assigned to the image you build. The default is the name of the branch or revision that is built.
  • tag_policy - The case-transformation policy for the tag name. One of original to keep tag name as is, or lowercase, the default, to convert to lowercase. For lowercase, tags in mixed case are pushed as image_name: .
  • tags - Multiple tags under which to push the image.
  • target - target stage in a multistage build (build will run until this stage)
  • working_directory - The directory in which the build command is executed. It can be an explicit path in the container’s file system, or a variable that references another step. The default is ${{main_clone}}.
    Docker-Build:
  title: Building docker image
  type: build
  working_directory: '${{CLONE_STEP_NAME}}'
  arguments:
    image_name: '${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}'
    tag: master

  
    GCBuild:
  title: Building docker image
  type: build
  working_directory: '${{CLONE_STEP_NAME}}'
  arguments:
    image_name: '${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}'
    tag: master
    provider:
      type: gcb
      arguments:
        google_app_creds: '${{G_CREDS_B64}}'
        cache:
          repo: '${{CF_REPO_OWNER}}/kaniko-cache'
          ttl: 10h
        timeout: 600s
        machineType: N1_HIGHCPU_8
        logsBucket: 'gs://your-project_id_cloudbuild/logs'
        diskSizeGb: 10

  
github.com
Codefresh INC
Mar 13, 2024