Overview
This documentation provides a detailed step-by-step guide on how the CI/CD deployment process can be configured and executed for the chainguard-dev/apko
project using the available tools and setups defined within the project’s Makefile. The goal is to facilitate seamless integration and delivery of builds through the use of automated processes that are robust and maintainable.
CI/CD Setup Steps
Prerequisites
Ensure the following tools are installed in your development environment:
- Go (version compatible with the project)
- Make
- Shell
1. Configuration of Makefile Targets
The Makefile
serves as a central configuration for managing builds and deployments in this project. Below are some essential targets that can be utilized in the CI/CD processes:
sign-image
: This target is responsible for signing images as part of the deployment process.sign-image: # Sign the Docker image using a specified signing tool docker sign --options ...
ko-local
: This target builds and manages local container images using theko
tool, which simplifies the process of handling Go applications as containers.ko-local: ko build ./... # Build all Go applications in the directory
generate
: This target can be used to generate configuration files or code that is necessary for deployment.generate: # Example command to generate configuration ./scripts/generate-config.sh
snapshot
: Creates a snapshot of the current state of the application, which can be useful for creating archived builds.snapshot: # Command to take a snapshot docker snapshot create ...
install
: This can be used to install dependencies before deployment.install: go get ./...
ko-resolve
: Resolves image references and prepares them for deployment.ko-resolve: ko resolve ./... # Resolve images for all specified applications
ko-apply
: Applies the built images to the Kubernetes cluster.ko-apply: ko apply ...
release
: This target can be utilized for versioning or preparing a release of the application.release: # Tag the release version bash ./scripts/release.sh
2. Continuous Integration Configuration
To set up CI, utilize your preferred CI tool (e.g., GitHub Actions, GitLab CI, Jenkins). Below is an example of a simple CI pipeline that uses GitHub Actions:
name: CI
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.x'
- name: Install Dependencies
run: make install
- name: Lint code
run: make lint
- name: Generate Code
run: make generate
- name: Build Images
run: make ko-local
- name: Sign Image
run: make sign-image
- name: Deploy to Kubernetes
run: |
make ko-resolve
make ko-apply
3. Continuous Deployment Configuration
For continuous deployment, similar principles can apply, but typically you would configure the steps to run on specific branches or tags:
name: CD
on:
push:
tags:
- 'v*.*.*' # Trigger deployment on version tags
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.x'
- name: Deploy to Kubernetes
run: |
make ko-resolve
make ko-apply
4. Testing in CI/CD
Incorporate testing within the CI/CD process to ensure code integrity:
- name: Run Tests
run: make test
Conclusion
This documentation provides an overview of how to establish CI/CD processes using the Makefile
within the chainguard-dev/apko
project. By utilizing the defined targets and integrating them into a CI/CD pipeline, developers can streamline the deployment process while ensuring quality and reliability in the handling of application builds.
For further details on specific commands or to add additional functionalities, refer to the Makefile documentation or integrate further tools as necessary in your workflows.