chainguard-dev / apko

Build OCI images from APK packages directly without Dockerfile
https://apko.dev
Apache License 2.0
1.13k stars 107 forks source link

Error "unsupported protocol scheme" while building #485

Closed nmeisenzahl closed 1 year ago

nmeisenzahl commented 1 year ago

Hi all,

I have an issue while building an apk with local packages. I'm getting the following error:

Error: failed to build layer image: initializing apk: failed to fixate apk world: error getting repository indexes: unable to get repository index at @local/aarch64/APKINDEX.tar.gz: Get "@local/aarch64/APKINDEX.tar.gz": unsupported protocol scheme ""
2023/02/02 17:51:20 error during command execution: failed to build layer image: initializing apk: failed to fixate apk world: error getting repository indexes: unable to get repository index at @local/aarch64/APKINDEX.tar.gz: Get "@local/aarch64/APKINDEX.tar.gz": unsupported protocol scheme ""
Error: exit status 1

My config:

  repositories:
    - https://packages.wolfi.dev/os
    - '@local /work/packages'
  packages:
    - busybox
    - ca-certificates-bundle
    - nghttp2
    - nodejs
    - wolfi-baselayout
    - hello-app@local

My build command:

nerdctl run --privileged --rm -it -v ${PWD}:/work -w /work --entrypoint /usr/bin/apko cgr.dev/chainguard/sdk build --debug --build-arch aarch64 apko.yaml hello-app hello-app.tar

My previous melange build finished successfully. The local packages folder contains the index file (packages/aarch64/APKINDEX.tar.gz) as well as the apk.

I'm getting the same error when including --repository-append /packages into the build command.

Any tip is welcome! Thanks Nico

nmeisenzahl commented 1 year ago

Ok, it looks like this is related to the used version. I'm getting the above error with tag latest-20230119 but latest-20230118 and older are working fine.

kaniini commented 1 year ago

This is likely due to the native golang implementation of apk.

kaniini commented 1 year ago

hey @deitch can you look at this one?

deitch commented 1 year ago

Yup

deitch commented 1 year ago

Yeah, it definitely is from that. There was an assumption that everything in repositories would be either a valid URL or a file path. Clearly, it is not.

Is the rule, as long as it starts with @local, then space, followed by a local file path? And what should be inside that local file path? Is it the same layout as at the URL, i.e. we can expect to see <path>/<arch>/APKINDEX.tar.gz, and each .apk file is similarly placed, as if it were on a Web server? Or is it something else?

nmeisenzahl commented 1 year ago

@deitch Maybe this helps?

ls -lisa packages/aarch64/
total 1424
54609703    0 drwxr-xr-x  4 nico  staff     128 Feb  2 19:13 .
54609702    0 drwxr-xr-x  3 nico  staff      96 Feb  2 19:13 ..
54609705    8 -rw-r--r--  1 nico  staff     852 Feb  3 14:18 APKINDEX.tar.gz
54609704 1416 -rw-r--r--  1 nico  staff  722922 Feb  3 14:18 hello-app--r0.apk
deitch commented 1 year ago

Yup that looks the same. We will add it in.

deitch commented 1 year ago

@nmeisenzahl I was reading through the description again. If you don't use pinned repositories, i.e. just put in /work/packages, it should work fine as is. It only matters if you need to support pinned packages.

We will add it, but if using just /work/packages helps you get past it for now, that would be good.

deitch commented 1 year ago

See #539