Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD does not understand ENV variables #691

Closed
cybersiddhu opened this issue Jun 4, 2019 · 3 comments · Fixed by #768
Closed

ADD does not understand ENV variables #691

cybersiddhu opened this issue Jun 4, 2019 · 3 comments · Fixed by #768
Labels
area/dockerfile-command For all bugs related to dockerfile file commands cmd/add help wanted Looking for a volunteer! kind/bug Something isn't working priority/p1 Basic need feature compatibility with docker build. we should be working on this next.

Comments

@cybersiddhu
Copy link

Hi,
Kaniko build is failing when i am trying add(ADD) a remote file using ENV variable. Here is a test case.

FROM busybox
ENV TEST_PLAN https://raw.githubusercontent.com/GoogleContainerTools/kaniko/master/docs/testplan.md
RUN echo $TEST_PLAN
ADD $TEST_PLAN ./plan.md

Here is the error

error building image: error building stage: lstat /workspace/https:/raw.githubusercontent.com/GoogleContainerTools/kaniko/master/docs/testplan.md: no such file or directory

I am using local dir workspace as my build context.

The above Dockerfile builds fine with both docker and buildah.
Am i missing something here or kaniko does not work with this instruction.

@tejal29
Copy link
Contributor

tejal29 commented Aug 9, 2019

@cybersiddhu Thanks for trying kaniko.

This is related to #718 where IsSrcsValid assumes source destination is in the build context.

IsSrcsValid should if src is a remote file url. if resolvedSources is a remote file then it should skip this check and fetch the file.

fi, err := os.Lstat(filepath.Join(root, resolvedSources[0]))

Feel free to submit a PR and we will take a look.

@N4rm0
Copy link
Contributor

N4rm0 commented Sep 15, 2019

Hi @tejal29,

I submitted a quick PR that should fix the issue.

By activating kaniko debug log on the OP's example, here is what I found out:

INFO[0006] ADD $TEST_PLAN ./plan.md                     
DEBU[0006] Resolved $TEST_PLAN to https:/raw.githubusercontent.com/GoogleContainerTools/kaniko/master/docs/testplan.md 
DEBU[0006] Resolved ./plan.md to plan.md

I had to squint my eyes to see that the protocol in the url is missing a slash after environment replacement.

The incriminating function is:

func ResolveEnvironmentReplacement(value string, envs []string, isFilepath bool) (string, error) {

I made a small fix, but IHMO we could have cleaner code by refactoring/removing isFilepath flag.

I can amend this PR in that sense.

@tejal29
Copy link
Contributor

tejal29 commented Sep 20, 2019

Thanks @N4rm0 looking t your PR now.

@tejal29 tejal29 added area/dockerfile-command For all bugs related to dockerfile file commands priority/p1 Basic need feature compatibility with docker build. we should be working on this next. labels Sep 27, 2019
tejal29 added a commit that referenced this issue Oct 4, 2019
Fix #691 - ADD does not understand ENV variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dockerfile-command For all bugs related to dockerfile file commands cmd/add help wanted Looking for a volunteer! kind/bug Something isn't working priority/p1 Basic need feature compatibility with docker build. we should be working on this next.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants