balena-io-modules / balena-compose

Complete toolkit for building docker-compose.yml files and optionally deploy them on balenaCloud
Apache License 2.0
8 stars 0 forks source link

Always fails to get manifest when the authentication is required #28

Open FantomJAC opened 1 year ago

FantomJAC commented 1 year ago

When the docker-compose file includes the image from the registry that requires authentication (e.g. ghcr.io) it always fails to get manifest with the following error (from build.ts)

debug(`${task.serviceName}: Image manifest data unavailable for ${r}`);

Reason is that inside getManifest function, it uses docker-modem library without passing any authentication info.

    const optsf = {
        path: `/distribution/${repository}/json?`,
        method: 'GET',
        statusCodes: {
            200: true,
            403: 'not found or not authorized',
            500: 'server error',
        },
    };

optsf shall include the object authconfig so docker-modem will encode it and use it as X-Registry-Auth.

FYI: https://docs.docker.com/engine/api/v1.42/#section/Authentication

This authentication info shall be derived from registry-secrets.yml file from Balena CLI, but that is also not the case.

As a result, it is currently impossible to use multiarch images from the major private repositories such as ghcr.io.