Overview

The CI/CD workflow for chainguard-dev/apko is essential in automating the build, test, and deployment processes for the project. Leveraging the power of Makefile, the project provides various functions that facilitate different stages of the CI/CD pipeline. This document outlines the specific tasks you can perform during the CI/CD process using the available tools and commands within the Makefile.

Available Commands in Makefile

The Makefile for chainguard-dev/apko includes the following commands relevant to the CI/CD workflow:

  • sign-image: Signs the image for verification and validation.
  • ko-local: Local build process using the ko tool.
  • generate: Generates project-related assets.
  • snapshot: Creates a snapshot of the current state.
  • install: Installs necessary dependencies or components.
  • ko-resolve: Resolves and prepares images.
  • ko-apply: Applies the image to a specified environment.
  • default: The default target, generally used for common tasks.
  • ko: Commands related to the ko toolkit.
  • clean: Cleans up the workspace and temporary files.
  • lint: Executes linting checks on the codebase.
  • golangci-lint: Runs linter with golangci-lint.
  • fmt: Formats the Go code according to standard conventions.
  • checkfmt: Checks if the code is formatted correctly.
  • ci: Executes continuous integration tasks.
  • help: Outputs help information on commands.
  • log-%: Logs various elements based on the specified parameter.
  • release: Handles release processes.
  • test: Runs the test suite for the project.
  • apko: Used for specific apko related tasks.

Step-by-Step CI/CD Workflow

Step 1: Setting Up the Environment

To begin the CI/CD workflow, ensure that your development environment is properly set up. This includes having Go installed and being able to execute Makefile commands.

Step 2: Cleaning Up the Workspace

Before starting the build process, it’s good practice to clean up any previous build artifacts. You can do this by executing:

make clean

This command will remove any intermediate files that could affect the build.

Step 3: Linting the Codebase

Run linting checks to ensure that the code adheres to the defined style guide. You can use the following command:

make lint

For a more comprehensive linting, you may leverage golangci-lint:

make golangci-lint

Step 4: Running Tests

Testing is a crucial step in the CI/CD workflow. Ensure that all tests pass before building the images:

make test

This command will execute the entire test suite, helping maintain code quality.

Step 5: Building the Project

Build the project using the provided ko command, which is designed for building container images:

make ko-local

This command compiles the code and prepares it for packaging.

Step 6: Signing the Image

After building the image, make sure to sign it to ensure authenticity:

make sign-image

This step is important for securing your deployment pipeline by ensuring that only verified images are deployed.

Step 7: Generating Necessary Artifacts

Generate the required assets or configurations:

make generate

This command helps in preparing configuration files and other necessary resources.

Step 8: Applying the Image

If you’re ready, apply the build image to your target environment:

make ko-apply

This step deploys the built image and your application code to the specified environment.

Step 9: Releasing the Build

If your build passes all the checks and is ready for production, you can trigger the release process:

make release

Ensure that you have followed all the best practices before tagging the release.

Conclusion

The CI/CD workflow for chainguard-dev/apko is designed to provide a streamlined process from code changes to deployment. By utilizing the provided commands in the Makefile, expert developers can ensure that their builds are robust, tested, and ready for deployment.

For more detailed information on the specific commands and their usage, refer to the Makefile directly as it contains embedded help for each command.

Source: Makefile (chainguard-dev/apko)