Summary
The user is asking if they can use the COPY command with ImageSpec, similar to how they can use the RUN command. They attempted to use the COPY command but encountered an error indicating that COPY was not found. They found that using image_spec.copy
works, but they express frustration that extra RUN commands are executed before COPY commands. The user suggests that the design pattern should allow for better composition and ordering, proposing that each with
method should return a new ImageSpec with the additional change while pointing to the original. They request assistance in improving this implementation.
denis.shvetsov
Thank you!
pingsutw
yup, we don’t support ordering for now. To wrokaround it, you can use nested imageSpec
image_spec = ImageSpec(base_image=ImageSpec(copy={...})).with_commands(...)
flytekit will build the first image that copy packages to the image, and then use it as base image for the second imageSpec
denis.shvetsov
Sure, I’ll make a more careful look in a spare time
habuelfutuh
The original intention of the design pattern is to allow composition and therefore ordering. I don't think the current implementation lives up to the premise. Would it be something you can help with?
The simplest fix in my opinion is that every with
should return a new ImageSpec with just the additional change (and points to the original as its base)
At image build time, we just run through the linked list in order.
<@USU6W5ATA> <@U0265RTUJ5B>
denis.shvetsov
denis.shvetsov
Though it is not very convenient that extra run commands are executed before extra copy commands. Is there any reason for that?
david.espejo
Sorry, for that one you should use .with_copy
denis.shvetsov
According to the code This command works
image_spec.copy = [
'./packages'
]```
denis.shvetsov
I tried
'COPY ./packages /packages'
)```
Got the error
```=> ERROR [stage-2 8/10] RUN COPY ./packages /packages 0.2s
------
> [stage-2 8/10] RUN COPY ./packages /packages:
0.142 /bin/sh: 1: COPY: not found
------
Dockerfile:29
--------------------
27 |
28 |
29 | >>> RUN COPY ./packages /packages
30 |
31 |
--------------------
ERROR: failed to solve: process "/bin/sh -c COPY ./packages /packages" did not complete successfully: exit code: 127```
Looks like it is still `RUN` command
david.espejo
Hey Denis, yes
Using .with_commands
you should be able to
denis.shvetsov
Hi all, with IamgeSpec I can execute RUN command, I also want to execute COPY command, am I able to do so?