Repositories - chainguard-dev/apko

Repositories in Apko files are defined using a YAML file in a declarative manner. Melange apks, which are built using Apko, are compatible with Alpine-based systems. However, it’s not possible to mix Alpine and Wolfi package repositories within the same build environment. Each repository in an Apko file is defined using the repositories directive in the YAML file. Here’s an example:

contents :
repositories :
- https://dl-cdn.alpinelinux.org/alpine/edge/main

In this example, the repositories directive is used to define a single repository with the URL https://dl-cdn.alpinelinux.org/alpine/edge/main. Apko supports both Alpine and Wolfi repositories.

Apko also provides a way to translate apko.lock.json files into Starlark code using the apko_repositories() function. This function takes a name, lock file, repository mapping, and target name as arguments. The repository mapping is a dictionary that maps local repository names to global repository names, allowing for better control over workspace dependency resolution.

translate_apko_lock(name="example_lock", lock="path/to/apko.lock.json", repo_mapping={"@foo": "@bar"}, target_name="")

In this example, the translate_apko_lock() function is used to generate Starlark code from an apko.lock.json file. The repo_mapping argument is used to map the local repository name @foo to the global repository name @bar.