redhat-buildpacks / poc

Project to be used to perform go build of images using Buildah, ...
3 stars 6 forks source link

kaniko CalculateDependencies fails due to "index out of range [0] with length 0" #6

Closed cmoulliard closed 2 years ago

cmoulliard commented 2 years ago

Issue

The following Dockerfile

ARG base_image
FROM ${base_image}

ARG some_arg
RUN echo ${some_arg} > /opt/arg.txt

ARG build_id=0
RUN echo ${build_id}

RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

fails to be processed

 docker run \
>        -e LOGGING_LEVEL=debug \
>        -e LOGGING_FORMAT=color \
>        -e base_image="ubtuntu:bionic" \
>        -e DOCKER_FILE_NAME=Dockerfile1 \
>        -v $(pwd)/workspace:/workspace \
>        -v $(pwd)/cache:/cache \
>        -it kaniko-app
Env var DEBUG: 
INFO[0000] Starting the Kaniko application to process a Dockerfile ... 
INFO[0000] Initialize the BuildPackConfig and set the defaults values ... 
DEBU[0000] Checking if the DOCKER_FILE_NAME env is defined... 
DEBU[0000] DOCKER_FILE_NAME=Dockerfile1                 
DEBU[0000] DockerfileName is: Dockerfile1               
DEBU[0000] KanikoOptions defined                        
INFO[0000] Kaniko      dir: /kaniko                     
INFO[0000] Workspace   dir: /workspace                  
INFO[0000] Cache       dir: /cache                      
INFO[0000] Dockerfile name: Dockerfile1                 
DEBU[0000] Building the Dockerfile1                     
DEBU[0000] Moving to kaniko home dir: /kaniko           
DEBU[0000] Building the Dockerfile1 ...                 
DEBU[0000] Built stage name to index map: map[]         

as kaniko CalculateDependencies reports a panic: runtime error: index out of range [0] with length 0

Stacktrace

goroutine 1 [running]:
github.com/GoogleContainerTools/kaniko/pkg/executor.CalculateDependencies(0xc0001e0000, 0x1, 0x1, 0xc00033e2a0, 0xc000047c50, 0x0, 0x0, 0x0)
        /go/src/kaniko-app/vendor/github.com/GoogleContainerTools/kaniko/pkg/executor/build.go:505 +0x160a
github.com/GoogleContainerTools/kaniko/pkg/executor.DoBuild(0xc00033e2a0, 0x0, 0x0, 0x0, 0x0)
        /go/src/kaniko-app/vendor/github.com/GoogleContainerTools/kaniko/pkg/executor/build.go:583 +0x60b
main.(*buildPackConfig).buildDockerFile(0xc00033e240, 0x0, 0x0)
        /go/src/kaniko-app/main.go:142 +0x296
main.main()
        /go/src/kaniko-app/main.go:84 +0x589