GoogleContainerTools / kaniko

Build Container Images In Kubernetes
Apache License 2.0
14.83k stars 1.44k forks source link

Copy with wildcard fails #3092

Open yossicohn opened 7 months ago

yossicohn commented 7 months ago

Actual behavior Does not COPY or fails Tested with KANIKO 1.22 still a bug both will fail: COPY ./* ./ or COPY ./*.json ./

Expected behavior Copy all Files as defined by the wildcard btw, COPY ./ ./ used to work once

To Reproduce Steps to reproduce the behavior:

  1. Docker file with COPY ./* ./ or COPY ./*.json ./
  2. content of files in the context

Additional Information This is painful bug

JeromeJu commented 7 months ago

Thanks for filing the bug @yossicohn ; could you specify the version of kaniko you're using and which release is the workable one?

yossicohn commented 7 months ago

@JeromeJu the latest I know of working is v1.12.0, in the process of upgrade to the latest I got all the issues of the COPY I mentioned above

prima101112 commented 7 months ago

Hi @yossicohn could you provide whats is the error or the behavior in your case? is it file not found, is it error or something else?

yossicohn commented 7 months ago

@prima101112 Examples and most painful COPY . . I get no error, but it does not copy anything vs. the original behavior of copying all the context files.

if I do COPY ./ssh/* ./ssh I get an error {"level":"info","msg":"Resolving srcs [.ssh/*]...","time":"2024-04-02T08:40:22Z"} error building image: error building stage: failed to get files used from context: copy failed: no source files specified

Same for other wildcards usages like *.jsonetc. btw, the following does work COPY ./ssh ./ssh

prima101112 commented 6 months ago

tested master branch with

COPY ./* ./

its copy all files. but dunno with COPY ./ ./ is the docker behavior will copy all files?

cc : @JeromeJu

yossicohn commented 6 months ago

@prima101112 as far as I can see the copied content via COPY ./* ./ is not really working, as it is not available. I tried it and the Folders are not available, cd into the folders fails

drwxrwxrwx    1 root     root            31 Apr 24 06:52 .
drwxr-xr-x    1 root     root            40 Apr 24 06:53 ..
lrwxrwxrwx    1 root     root            51 Apr 24 06:52 myfolder -> .worktrees/e15ba753ddeafecc38225a329b90f69a9ef70545
# cd myfolder
/bin/sh: cd: can't cd to myfolder: No such file or directory

Regarding COPY ./ ./ or COPY ./ssh/* ./ssh or COPY ./*.json ./ all these are not working as for v1.22 and are very needed behavior and feature

Can you recheck this?

yossicohn commented 5 months ago

@prima101112 hi, FYI I've just tested the version v1.23.0 and the issues describes still persist

prima101112 commented 5 months ago

@yossicohn will check it

prima101112 commented 5 months ago

Hi @yossicohn just try and test using latest 1.23 and its work fine

INFO[0004] Initializing snapshotter ...                 
INFO[0004] Taking snapshot of full filesystem...        
INFO[0004] Cmd: /bin/sh                                 
INFO[0004] Args: [-c mkdir -p /etc/ssh/testfolder]      
INFO[0004] Running: [/bin/sh -c mkdir -p /etc/ssh/testfolder] 
INFO[0004] Taking snapshot of full filesystem...        
INFO[0004] WORKDIR /app                                 
INFO[0004] Cmd: workdir                                 
INFO[0004] Changed working directory to /app            
INFO[0004] Creating directory /app with uid -1 and gid -1 
INFO[0004] Taking snapshot of files...                  
INFO[0004] COPY . .                                     
INFO[0004] Taking snapshot of files...                  
INFO[0004] RUN ls /app                                  
INFO[0004] Cmd: /bin/sh                                 
INFO[0004] Args: [-c ls /app]                           
INFO[0004] Running: [/bin/sh -c ls /app]                
Dockerfile
config.json
howtorun.txt
known
INFO[0004] Taking snapshot of full filesystem...        
INFO[0004] No files were changed, appending empty layer to config. No layer added to image. 
INFO[0004] Skipping push to container registry due to --no-push flag 
gmuth commented 5 months ago

I got similar error but related to --from. Issue seems that kaniko does not support fully qualified image names including registry. adding FROM as bla and then use COPY --from=bla enabled me to use wildcards.

SamuZad commented 3 days ago

Wildcard in copy still seems to fail, even in the latest version

INFO[0008] COPY ../package.json ./                                            
INFO[0008] Taking snapshot of files...                  
INFO[0008] Resolving srcs [../*-lock.json]...           
WARN[0008] No files to copy                             
INFO[0008] COPY ../*-lock.json ./                       
INFO[0008] Resolving srcs [../*-lock.json]...                                    
INFO[0008] Taking snapshot of full filesystem...        
INFO[0009] No files were changed, appending empty layer to config. No layer added to image. 
INFO[0009] RUN ls -la                                   
INFO[0009] Cmd: /bin/sh                                 
INFO[0009] Args: [-c ls -la]                            
INFO[0009] Running: [/bin/sh -c ls -la]                 
total 12
drwxr-xr-x    2 root     root          4096 Nov  1 17:17 .
drwxr-xr-x    1 root     root          4096 Nov  1 17:17 ..
-rw-r--r--    1 root     root          1042 Nov  1 17:17 package.json