Packages - chainguard-dev/apko

Apko is a command-line tool used to build container images using a declarative language based on YAML. It is inspired by the ko build tool and uses the APK package format. Apko is part of the open-source toolkit developed by Chainguard to build Wolfi and Chainguard Images. Melange is another tool in the same ecosystem that interacts with apko for building apk-based images, using either Alpine or Wolfi as base systems.

To install and manage packages using apko, follow these steps:

  1. First, you need to define your packages and repositories in a YAML file. Here’s an example:
contents:
repositories:
- https://dl-cdn.alpinelinux.org/alpine/edge/main
packages:
- alpine-base
  1. Save this YAML file in a new file named Dockerfile.apko or apko.yml in your project directory.

  2. Install apko by following the getting started guide:

a. If you’re using Debian or Ubuntu, run:

sudo apt-get install apko

b. If you’re using Alpine, run:

apk add apko
  1. Build your image using apko:
apko build

This command will install all the packages listed in your YAML file and create a new container image.

  1. To verify the signature of the built image, you can use Sigstore’s cosign tool. First, you need to obtain the image’s certificate:
apko export <image-name> > image.tar.gz
cosign export image.tar.gz > image.tar.gz.crt

Then, you can verify the signature using the following command:

cosign verify-blob <image.tar.gz> --cert image.tar.gz.crt

For more information, you can refer to the official documentation:

These resources provide detailed information about using apko, including examples and best practices.